0% found this document useful (0 votes)
3 views

Arduino

The document defines variables for 3 LED pins and an LDR pin, sets the pins as outputs in setup, and uses analogRead to check the LDR value in loop to light different LEDs depending on the LDR reading.

Uploaded by

maritusan09
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Arduino

The document defines variables for 3 LED pins and an LDR pin, sets the pins as outputs in setup, and uses analogRead to check the LDR value in loop to light different LEDs depending on the LDR reading.

Uploaded by

maritusan09
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

int pinLed1 = 11;

int pinLed2 = 12;


int pinLed3 = 13;

int pinLDR = A0;

int valorLDR = A0;


void setup()
{
pinMode(pinLed1, OUTPUT);
pinMode(pinLed2, OUTPUT);
pinMode(pinLed3, OUTPUT);
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop()
{
digitalWrite(pinLed1, LOW);// put your main code here, to run
repeatedly:
digitalWrite(pinLed2, LOW);
digitalWrite(pinLed3, LOW);

valorLDR= analogRead(pinLDR);

if(valorLDR > 256)


{
digitalWrite(pinLed1, HIGH);
}
if(valorLDR > 512)
{
digitalWrite(pinLed2, HIGH);
}
if(valorLDR > 700)
{
digitalWrite(pinLed3, HIGH);
}

delay(200);
}

You might also like