arduino_
illumination_sensor (조도센서)
파아랑새
2016. 2. 13. 20:34
방에 불을 끄면 어두워서 --> led On
const int led_yellow_pin = 13;
const int illumination_sensor = A0;
int value;
void setup() {
// put your setup code here, to run once:
pinMode(led_yellow_pin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
value = analogRead(illumination_sensor);
Serial.println(value);
if ( value < 100) {
digitalWrite(led_yellow_pin, HIGH);
} else {
digitalWrite(led_yellow_pin, LOW);
}
}