Hardware Reference
In-Depth Information
Figure 11-17: Wireless incoming data shown with the serial monitor
6. After you have confirmed that data is coming in, close the serial monitor
and run the Processing sketch to adjust the window's color based on the
incoming data.
Before starting the sketch, ensure that you have the proper serial port
selected. Listing 11-2 repeats the code.
Listing 11-2: Processing Code to Read Data and Change Color on the Screen— pot_to_
processing/processing_display_color
//Processing Sketch to Read Value and Change Color on the Screen
//Import and initialize serial port library
import processing.serial.*;
Serial port;
float brightness = 0; //For holding value from pot
void setup()
{
size(500,500); //Window size
port = new Serial(this, "COM3", 9600); //Set up serial
port.bufferUntil('\n'); //Set up port to read
//until newline
}
void draw()
{
Search WWH ::




Custom Search