Hardware Reference
In-Depth Information
As in previous Processing examples that you've run, the sketch starts by
importing the serial library and setting up the serial port. In setup() , you are
defining the size of the display window, loading the font you just created, and
setting up the serial port to buffer until it receives a period. draw() fills the
background in black and prints out the Celsius and Fahrenheit values in two
colors. With the fill() command, you are telling Processing to make the next
element it adds to the screen that color (in RGB values). serialEvent() is called
whenever the bufferUntil() event is triggered. It reads the buffer into a string,
and then breaks it up based on the location of the comma. The two temperature
values are stored in variables that get printed out in the application window.
When you execute the program, the output should look like the results shown
in FigureĀ 8-10.
Figure 8-10: Processing temperature display
When you squeeze the sensor, the Processing display should update, and the
lights on your board should illuminate.
NOTE Towatchademovideoofthetemperaturemonitoringhardwareand
Processingsystem,checkout www.exploringarduino.com/content/ch8 .
YoucanalsofindthisvideoontheWileywebsiteshownatthebeginningofthis
chapter.
Search WWH ::




Custom Search