what am I missing? keypress and key functions
in
Programming Questions
•
2 years ago
i'm trying to write a key value trough serial to be read by the arduino.
In this case I want to press the w key and want the corresponding value "119" to be sent to myPort variable.
This is based on an example, and with this code nothing happens when I strike the key.
I wrote " print("the w key as been pushed");" to verify the if statement, which is not working.
(first day on processing so pls be kind :P)
import processing.serial.*;
// The serial port:
Serial myPort;
// List all the available serial ports:
println(Serial.list());
myPort = new Serial(this, Serial.list()[1], 9600);
if (keyPressed == true)
{
if (key == 'w' || key == 'W')
{
// Send a w out the serial port
myPort.write(119);
print("the w key as been pushed");
}
}
1