Descripción del laboratorio : Controlaremos 8 leds desde el arduino haciendo que se muevan secuencial mente de izquierda a derecha, el tiempo de encendido y apagado los definimos nosotros en el programa.
Materiales:
- Protoboard
- 8 Resistencias
- Cables
- 8 Leds
- Arduino Uno
- Cable UTP
DIAGRAMAS:
MONTAJE EN PROTOBOARD:
VIDEO:
CODIGO:
- #define MAXLED 8
- int led[MAXLED] = {2,3,4,5,6,7,8,9};
- void setup() {
- for (int i=0; i<MAXLED; i++)
- pinMode(led[i], OUTPUT);
- }
- void loop() {
- for (int i=0; i<MAXLED; i++)
- {
- prender(led[i], 50);
- apagar(led[i], 100);
- }
- for (int i=6; i>0; i--)
- {
- prender(led[i], 50);
- apagar(led[i], 50);
- }
- }
- void prender(int l,int t) {
- digitalWrite(l, HIGH);
- delay(t);
- }
- void apagar(int l,int t) {
- digitalWrite(l, LOW);
- delay(t);
- }



No hay comentarios:
Publicar un comentario