A simple way to test the serial with just your computer is to get 2 USB->Serial connections (RS232), a serial cable and connect them together (USB/Serial-->SerialCable-->Serial/USB) and then you can output and read serial information. This may help in testing Processing code if an Arduino is not available (as is in my case; waiting for it to arrive, but have an assignment due before then!) Here is a simple serial read on Processing.
| Name | read() |
|---|---|
| Examples | // Example by Tom Igoe
import processing.serial.*;
Serial myPort; // The serial port
void setup() {
// List all the available serial ports
println(Serial.list());
// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[0], 9600);
}
void draw() {
while (myPort.available() > 0) {
int inByte = myPort.read();
println(inByte);
}
}
|
No comments:
Post a Comment