1
SKILL
LEVEL
Ringo Educational Guide Rev04.1 ~ Plum Geek
Using Ringo’s Light Sensors
Using top side light sensors when Ringo’s eyes are lit up...
Have a close look at Ringo’s eyes. You’ll notice that a NeoPixel LED shines through
the clear ambient light sensor. Whenever the NeoPixel is turned on (Ringo’s eyes
are lit up), this light from the NeoPixel is picked up by the top side light sensor
directly in front of it. If you have Ringo’s eyes lit up and want to read the light
sensors, you will need to briefly turn off Ringo’s eyes before reading the light
sensors. The sensor read is very quick (about 100 microseconds per sensor) which
is much too fast for your eye to see. If Ringo’s NeoPixel eye lights are turned off,
then the light sensors are read, then the eye lights are turned back on immediately
following, it will appear that Ringo’s eyes were lit up the entire time.
Try this code and see what happens:
#include “RingoHardware.h” //include Ringo background functions
int sensorRight; //declares variable “sensorRight”
int sensorLeft; //declares variable “sensorLeft”
int sensorRear; //declares variable “sensorRear”
void setup(){
HardwareBegin(); //initialize Ringo’s circuitry
PlayStartChirp(); //play startup chirp and blink eyes
digitalWrite(Source_Select, HIGH);
//select top side light sensors
}
void loop(){
SetAllPixelsRGB(0,0,0);
//turn off all NeoPixel lights
delay(2);
//delay 2 milliseconds. Important!
sensorLeft = analogRead(LightSense_Left); //read left light sensor
sensorRight = analogRead(LightSense_Right); //read right light sensor
sensorRear = analogRead(LightSense_Rear); //read rear light sensor
// ... continued on next page ....