YARPF

Raspberry Pi Logo YetAnotherRaspberryPiFanpage

6.1 - Un LDR y un LED

Plan

wiring plan

Board

bread board

Code

int pinLDR = A1;
int pinLED = 13;

int valSensor;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
   valSensor = analogRead(pinLDR);

   Serial.println(valSensor);

   if (valSensor < 200) {
    digitalWrite(pinLED, HIGH);
   }
   else {
    digitalWrite(pinLED, LOW);
   }

   delay(1000);
}

Download

Fritzing: ldr_led.fzz

Comments ?

blog comments powered by Disqus