Can't even execute "SimpleRead" example.
in
Core Library Questions
•
1 year ago
Hi.
I'm trying the examples and each time there is a serial port to read, my process stop and I recieve the message below:
Here is the SimpleRead example Code :
Can someone help me?
Thanks.
I'm trying the examples and each time there is a serial port to read, my process stop and I recieve the message below:
processing.app.SketchException: Badly formed character constant (expecting quote, got s)
at processing.mode.java.preproc.PdePreprocessor.checkForUnterminatedMultilineComment(PdePreprocessor.java:454)
at processing.mode.java.preproc.PdePreprocessor.write(PdePreprocessor.java:490)
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:270)
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:185)
at processing.mode.java.JavaBuild.build(JavaBuild.java:144)
at processing.mode.java.JavaBuild.build(JavaBuild.java:123)
at processing.mode.java.JavaMode.handleRun(JavaMode.java:160)
at processing.mode.java.JavaEditor$19.run(JavaEditor.java:473)
at java.lang.Thread.run(Thread.java:680)
Here is the SimpleRead example Code :
- /**
* Simple Read
*
* Read data from the serial port and change the color of a rectangle
* when a switch connected to a Wiring or Arduino board is pressed and released.
* This example works with the Wiring / Arduino program that follows below.
*/
import processing.serial.*;
Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
void setup()
{
size(200, 200); - /****** I know that the first port in the serial list on my mac
is always my FTDI adaptor, so I open Serial.list()[0].
On Windows machines, this generally opens COM1.
Open whatever port is the one you're using.********/ - /***********************************Above you can see that the guy who wrote this code worke on a mac like me
- ************************************That's why I tried this example.*/
String portName = Serial.list()[0];
myPort = serial.Serial(port='/dev/tty.usbmodemfd131', 9600);
}
void draw()
{
if ( myPort.available() > 0) { // If data is available,
val = myPort.read(); // read it and store it in val
}
background(255); // Set background to white
if (val == 0) { // If the serial value is 0,
fill(0); // set fill to black
}
else { // If the serial value is not 0,
fill(204); // set fill to light gray
}
rect(50, 50, 100, 100);
}
/*
// Wiring / Arduino Code
// Code for sensing a switch status and writing the value to the serial port.
int switchPin = 4; // Switch connected to pin 4
void setup() {
pinMode(switchPin, INPUT); // Set pin 0 as an input
Serial.begin(9600); // Start serial communication at 9600 bps
}
void loop() {
if (digitalRead(switchPin) == HIGH) { // If switch is ON,
Serial.print(1, BYTE); // send 1 to Processing
} else { // If the switch is not ON,
Serial.print(0, BYTE); // send 0 to Processing
}
delay(100); // Wait 100 milliseconds
}
*/
Can someone help me?
Thanks.
1