Fecha de publicación: 14-ene-2016 12:32:56
Montaje en 123DCircuits:
Código en Arduino:
// Pin 3 has an LED connected on most Arduino boards.
// give it a name: Creamos la variable led para darle el valor del pin que vamos a usar
int led1 = 8;
int led2 = 4;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output. seleccionamos el pin led=3 como salida
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level). Encendemos el led
delay(1000); // wait for a second
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level). Encendemos el led
delay(1000); // wait for a second
digitalWrite(led1, LOW); // turn the LED off by making the voltage LOW. Lo apagamos
delay(1000); // wait for a second. Cada segundo se vuelve a iniciar el programa, por eso se enciende y se apaga
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW. Lo apagamos
delay(1000); // wait for a second. Cada segundo se vuelve a iniciar el programa, por eso se enciende y se apaga
}
Vídeo del funcionamiento: