Clase 3 de fundamentos de Arduino: Flowing LED lights - Luces LED que fluyen

Introducción de la clase de Flowing LED lights - Luces LED que fluyen

 

En esta lección, realizaremos un experimento simple pero interesante: usar LED para crear luces LED que fluyan. Como su nombre lo indica, estas luces que fluyen están formadas por ocho LED en una fila que se iluminan sucesivamente y se atenúan una tras otra como el agua que fluye.

 

Componentes 

{Product:2000}{Product:1436}{Product:287}{Product:603}{Product:13}

Principio

El principio de este experimento es simplemente encender ocho LED del modo descrito en la introducción.

 

Procedimiento

Paso 1: conecta el circuito como se muestra en el siguiente diagrama.

El diagrama esquemático correspondiente es el siguiente:

 

               

Paso 2: Programa (consulta el código de ejemplo en el CD o en la web oficial)

/* Eight LEDs will light up one by one from left to right, and then go out one by one from right to left.

After that, the LEDs will light up one by one from right to left, and then go out one by one from left to right.

This process will repeat indefinitely.*/

//Email:[email protected]

//Website:www.sunfounder.com

//2015.5.7

/**************************************/

const int lowestPin = 2;//the lowest one attach to pin 2

const int highestPin = 9;//the highest one attach to pin 9

/**************************************/

void setup()

{

//set pins 2 through 9 as output 

for(int thisPin = lowestPin;thisPin <= highestPin;thisPin++)

{

pinMode(thisPin,OUTPUT); //initialize thisPin as an output

}

/****************************************/

void loop()

{

//iterate over the pins

//turn the led on from lowest to the highest

for(int thisPin = lowestPin;thisPin <= highestPin;thisPin++)

{

digitalWrite(thisPin,HIGH);//turn this led on

delay(100);//wait for 100 ms

}

//fade from the highest to the lowest

for(int thisPin = highestPin;thisPin>=lowestPin;thisPin--)

{

digitalWrite(thisPin,LOW);//turn this led off

delay(100);//wait for 100 ms

}

for(int thisPin = highestPin;thisPin>=lowestPin;thisPin--)

{

digitalWrite(thisPin,HIGH);//turn this led on

delay(100);//wait for 100 ms

}

for(int thisPin = lowestPin;thisPin <= highestPin;thisPin++)

{

digitalWrite(thisPin,LOW);//turn this led off

delay(100);//wait for 100 ms

}

} )

Paso 3: Compila el programa

Paso 4: Graba el programa en la placa Uno

Aquí deberías ver que ocho LEDs se iluminan uno por uno de izquierda a derecha y se apagan uno por uno de derecha a izquierda. Este proceso se repetirá ininterrumpidamente.

            

Resumen del experimento

Este sencillo experimento ayuda a aumentar la competencia en la aplicación de los  LEDs. Además, puedes modificar el programa proporcionado para crear todo tipo de patrones fantásticos.