DESCRIPCIÓN DEL LABORATORIO:
Controlar 8 LEDs desde el Arduino, un LED encendido que se mueve en forma continua de izquierda a derecha, usando los valores de dos potenciometros para controlar los tiempos que el LED permanece encendido y apagado.
MATERIALES :
- Protoboard
- Cable UTP
- 8 Resistencias
- Arduino
- 2 Potenciometros
- Cables
- 8 leds
MONTAJE EN PROTOBOARD:

ESQUEMATICO:

FOTOS DEL MONTAJE:
VIDEO:
CODIGO :
- #define MAXLED 8
- #define pot1 A0
- #define pot2 A1
- int led[MAXLED] = {2,3,4,5,6,7,8,9};
- void setup()
- {
- for (int i=0; i<MAXLED; i++)
- {
- pinMode(led[i], OUTPUT);
- }
- pinMode(pot1, INPUT);
- pinMode(pot1, INPUT);
- }
- void loop()
- {
- for (int i=0; i<=MAXLED; i++)
- {
- int on = analogRead(pot1);
- int t1=map(on, 0, 1023, 0, 1000);
- int off = analogRead(pot2);
- int t2=map(off, 0, 1023, 0, 1000);
- prender(led[i],t1);
- apagar(led[i],t2);
- }
- for (int i=6; i>0; i--)
- {
- int on = analogRead(pot1);
- int t1=map(on, 0, 1023, 0, 1000);
- int off = analogRead(pot2);
- int t2=map(off, 0, 1023, 0, 1000);
- prender(led[i],t1);
- apagar(led[i],t2);
- }
- }
- void prender(int i, int t)
- {
- digitalWrite(i, HIGH);
- delay(t);
- }
- void apagar(int i, int t)
- {
- digitalWrite(i, LOW);
- delay(t);
- }
No hay comentarios:
Publicar un comentario