How would one go about creating a small window in a processing project that displays the:
Serial.println(" ");
defined on a connected Arduino?
Basically I want to send a command from Processing, to an Arduino and have the above " Serial.println(" "); " on the Arduino tell a Processing window that the command has been received. This works great with just the Arduino sending notifications back, and Processing is doing a fine job of delivering the commands to the Arduino; I just don't know where to begin on getting notifications back from the Arduino, through Processing.
__________
Example:
Arduino:
Example:
Arduino Code:
void setup() { // initialize serial communication: Serial.begin(9600); // initialize the pins: for (int thisPin = 2; thisPin < 12; thisPin++) { pinMode(thisPin, OUTPUT ); } }
void loop() { // read the sensor: if (Serial.available() > 0) { int inByte = Serial.read();
// Single quotes will tell the controller to get the ASCII value for the character. // Example 'a' = 97, 'b' = 98, and so forth:
switch (inByte) {
//Hello World Print Test:
case 'q': Serial.println("Hello World"); break;
} } }
Processing:(Everything except the part that shows me the " Serial.println("Hello World"); " from the Arduino)
//Hello World Test (Minus the Print console)
// load the serial library for Processing import processing.serial.*; // instance of the serial class Serial myport;
// set the font PFont myFont;
void setup() { // screen size of the program size(250, 250);
// List all the available serial ports in the output pane. println(Serial.list());
// set the font to use myFont = createFont("verdana", 12); textFont(myFont);
myport = new Serial(this, Serial.list()[0], 9600); } void draw() { background(0); noStroke(); fill(150); // Text Label text("Hello World (q)", 5, 5, 200, 75);
// start looking to see whats pressed and send a value // over the serial port if(keyPressed) {