Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
46 views2 pages

Luces Navideñas Automática Con Arduino

This Arduino code controls an automatic Christmas light display that turns on when it gets dark. It uses a photoresistor to detect light levels and triggers a sequence of 10 LEDs lighting up in order when it senses darkness. The LEDs are connected to digital pins 4-13 and the code uses delays to control the timing and looping of the light pattern.

Uploaded by

Moises Mendoza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views2 pages

Luces Navideñas Automática Con Arduino

This Arduino code controls an automatic Christmas light display that turns on when it gets dark. It uses a photoresistor to detect light levels and triggers a sequence of 10 LEDs lighting up in order when it senses darkness. The LEDs are connected to digital pins 4-13 and the code uses delays to control the timing and looping of the light pattern.

Uploaded by

Moises Mendoza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Luces navideñas automática con arduino

/*
Luces Auto fantastico encendidas por la oscuridad
Por: http://elprofegarcia.com/
*/

int vel=100; // Velocidad de la secuencia


int valoroscuridad=200; // valor de la oscuridad
int valorfoto = 0; // valor de la fotorresistencia

void setup() {

pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);

void loop() {

valorfoto = analogRead(A5); // lee el valor de la oscuridad


if (valorfoto>valoroscuridad){ // si hay oscuridad
digitalWrite(13, HIGH);
delay(vel);
digitalWrite(12, HIGH);
delay(vel);
digitalWrite(11, HIGH);
delay(vel);
digitalWrite(13, LOW);
digitalWrite(10, HIGH);
delay(vel);
digitalWrite(12, LOW);
digitalWrite(9, HIGH);
delay(vel);
digitalWrite(11, LOW);
digitalWrite(8, HIGH);
delay(vel);
digitalWrite(10, LOW);
digitalWrite(7, HIGH);
delay(vel);
digitalWrite(9, LOW);
digitalWrite(6, HIGH);
delay(vel);
digitalWrite(8, LOW);
digitalWrite(5, HIGH);
delay(vel);
digitalWrite(7, LOW);
digitalWrite(4, HIGH);
delay(vel);
digitalWrite(6, LOW);
delay(vel);
digitalWrite(5, LOW);
delay(vel);
digitalWrite(5, HIGH);
delay(vel);
digitalWrite(6, HIGH);
delay(vel);
digitalWrite(4, LOW);
digitalWrite(7, HIGH);
delay(vel);
digitalWrite(5, LOW);
digitalWrite(8, HIGH);
delay(vel);
digitalWrite(6, LOW);
digitalWrite(9, HIGH);
delay(vel);
digitalWrite(7, LOW);
digitalWrite(10, HIGH);
delay(vel);
digitalWrite(8, LOW);
digitalWrite(11, HIGH);
delay(vel);
digitalWrite(9, LOW);
digitalWrite(12, HIGH);
delay(vel);
digitalWrite(10, LOW);
digitalWrite(13, HIGH);
delay(vel);
digitalWrite(11, LOW);
delay(vel);
digitalWrite(12, LOW);
}
else{
digitalWrite(13, LOW);
}
}

You might also like