26/03/2015

Sphero with Processing

For some days, i'm trying to use Processing to drive Sphero, with this code (Working on Windows) :

import processing.serial.*;

Serial Serialout ;
Serial Serialin;

void setup() {
  // List all the available serial ports:
  println(Serial.list());
  Serialout = new Serial(this, Serial.list()[0], 115200); // COM3 output SPHERO-BPG 'RN-SPP'
  Serialin = new Serial(this, Serial.list()[1], 115200); // COM4 input SPHERO-BPG
  println("Sphero turns blue, --> it is connected to output "+Serialout);
  println("Sphero turns blue, --> it is connected to input "+Serialin);
}

void draw() {
  while (Serialin.available ()>0) {
    println(Serialin.read());
  }
  while (Serialout.available ()>0) {
    println(Serialout.read());
  }
  // print ("but there is no data to read ! GRRRRR!");
}

void keyPressed() {
  Serialout.dispose();
}



Sphero is connected because it turns blue, and disconnected when I press a key, but i can't read/send any data using https://www.processing.org/reference/libraries/serial/ or other bluetooth library.
I don't understand how I could get SpheroName, and other info, how to send commands ?

Could someone help me ?

Aucun commentaire:

Enregistrer un commentaire