Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

Flow Control > Flow Control - Pg. 69

THE SIMPLEST NETWORK 69 8 To make this happen, first add while (Serial.available() <= 0) { Serial.println("hello"); delay(300); } // send a starting message the following lines to the startup() of the Arduino program. This makes the Arduino send out a serial message until it gets a response from Processing: 8 Next, wrap the whole of the loop() method in the Arduino program (the Sensor Reader program shown back in the beginning of the "Project #1: Monski pong" section) in an if() statement like this: void loop() { // check to see whether there is a byte available // to read in the serial buffer: if (Serial.available() > 0) { // read the serial buffer; // you don't care about the value of // the incoming byte, just that one was // sent: int inByte = Serial.read(); // the rest of the existing main loop goes here // ... } } Next, add some code to the Monski pong Processing program.