Hello,
I'm looking to get my Stamp to send data to Processing via Serial. Having seen the other topics on the boards my basic test is to first get the DEBUG working.
What I have on the stamp as a test is:
--------------------------------------------
' {$STAMP BS2}
Main:
DEBUG "ah"
'SEROUT 16, 16572, ["ah"] 'should work like DEBUG
PAUSE 10
GOTO main
--------------------------------------------
Now in reality I'd want to send Serial info on a button press, but to send so rapidly was the only way to get any response out of processing at all.
With the following code I get the first few characters and then nothing. Then if I close and reopen the port I get the same thing: a few characters and then nothing.
When I open a new debug window in the Basic Stamp editor all the debugging appears with no problem at all.
Any advice most welcome.
I'm on XP running p0115 and going straight into COM1, no USB (although it did do the same thing going through a FTDI interface to a USB COM port).
Thanks,
andy
Here's my processing code:
Quote:
import processing.serial.*;
PFont f;
Serial port;
int last;
void setup() {
size(500, 500);
f = loadFont("Alba-48.vlw");
textFont(f, 32);
// Print a list in case COM1 doesn't work out
println("Available serial ports:");
println(Serial.list());
fill(255);
println("selecting: "+ Serial.list()[0]);
port = new Serial(this, Serial.list()[0], 9600);
port.clear();
}
void draw(){
fill(0,0,0,10);
rect(0,0,width, height);
fill(255);
text(""+port, 0, 100);
text(""+port.available(), 0, 150);
text("rate: "+port.rate, 0, 200);
text("parity: "+port.parity, 0, 220);
text("stopbits: "+port.stopbits, 0, 240);
while (port.available() > 0) {
int value = port.read();
serialEvent(value);
}
}
void serialEvent(int v) {
println("serial input: "+v);
fill(255);
last = v;
text(last, 0, 130);
}
void keyPressed(){
if (key=='s') {
println("closing port");
port.stop();
}
else if (key=='o') {
println("opening port");
port = new Serial(this, Serial.list()[0], 9600);
port.clear();
}
else if (key=='c'){
println("clearing port");
port.clear();
}
}