Hardware Reference
In-Depth Information
Figure 6-15: Processing color selection screen
Every time the mouse button is pressed, the mousePressed() function is called.
The color of the pixel where you clicked is saved to a color object named c . The
get() method tells the application where to get the color from (in this case, the
location of the mouse's X and Y position in the sketch). The sketch converts the
object c into a string that can be sent to the Arduino by converting to integers
representing red, green, and blue. These values are also printed to the Processing
console so that you can see what is being sent.
Ensure that the Arduino is connected and programmed with the code from
ListingĀ 6-5. Run the processing sketch (with the correct serial port specified) and
click around the color map to adjust the color of the LED connected to your Arduino.
LearningSpecialTrickswiththeArduinoLeonardo
(andOther32U4-BasedArduinos)
The Leonardo, in addition to other Arduinos that implement MCUs that con-
nect directly to USB, has the unique ability to emulate nonserial devices such
as a keyboard or mouse. In this section you learn about using a Leonardo to
 
Search WWH ::




Custom Search