Hardware Reference
In-Depth Information
The red , green , and blue parameters are ints and represent the brightness
of the corresponding color. (Acceptable values ranging from 0 to 255 included.)
It is possible to write a single color value using the writeRed() , writeGreen() ,
and writeBlue() functions.
Again, each parameter is an int and accepts values between 0 and 255. Writing
to one color does not affect the other components.
By writing an individual color, the sketch may no longer know what color
value was written. For example, if the red value changes based on an external
input, the main program might not know what the value of the red LED is. It is
possible to read these values after writing them by using readRed() , readGreen() ,
and readBlue() .
redResult = Esplora.readRed();
greenResult = Esplora.readGreen();
blueResult = Esplora.readBlue();
Each of these functions returns an int representing the brightness of the LED.
To turn the LED off, use writeRGB() with all parameters set at zero (the value
of the red, green, and blue is off).
Esplora.writeRGB(0, 0, 0); // Turn the LED off
The Arduino Esplora has an integrated linear potentiometer in the form of a
slider. This component, connected to an analog-to-digital converter, can give
values between 0 (0 Volts) to 1,023 (5 Volts). To read the value, use readSlider() .
result = Esplora.readSlider();
This function does not take any parameters and returns an int , the value of
the position of the potentiometer.
The Arduino Esplora also has a light sensor that is connected in the same way.
It also returns values between 0 and 1,023; the more light, the higher the value.
result = Esplora.readLightSensor();
Also available on the list of sensors, the Esplora has a temperature sensor.
The temperature can be read using readTemperature() .
result = Esplora.readTemperature(scale);
Search WWH ::

Custom Search