Data Sheet

4/27/2018 OpenCR1.0
http://emanual.robotis.com/docs/en/parts/controller/opencr10/ 39/50
7. 7. Sensors
7. 7. 1. Ambient Light Sensor
It is ambient light sensor test on the OpenCR board.
Pinouts
Green : Signal
Red : Vcc
Black : Gnd
Specification
ambient light sensor specification
Supply Voltage : 3.3V to 5V
Illumination range : 1 Lux to 6000 Lux
Interface : Analog
7. 7. 1. 1. Code
LED turns off/on sequentially depending on the light received by the sensor.
LED turns off in bright place. If it is dark place, the LED turns on.
This sensor is an analog sensor, connect it to port A0.
It is a code that turns on/off the LED depending on the brightness of light changes.
#define BDPIN_LED_USER_1 23
#define BDPIN_LED_USER_2 24
#define BDPIN_LED_USER_3 25
void setup()
{
Serial.begin(9600);
pinMode(BDPIN_LED_USER_1, OUTPUT);
pinMode(BDPIN_LED_USER_2, OUTPUT);
pinMode(BDPIN_LED_USER_3, OUTPUT);
}
void loop()
{
if(analogRead(0)<200)
{
digitalWrite(BDPIN_LED_USER_1, LOW);
digitalWrite(BDPIN_LED_USER_2, LOW);
digitalWrite(BDPIN_LED_USER_3, LOW);
}
else if(analogRead(0)>200 && analogRead(0)<300)
OpenCR1.0
Back to Top ▲