Lo primero que hicimos fue copiar el codigo inicial “blink” y hacer el montaje correspondiente con los leds.
Tras esto lo modificamos:
- Para que se encendiera cuando se le diera al pulsador .
- Para que hubiera dos leds intermitentes.
- Para que hubiera 3 leds con un patrón. Codigo:
*/
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 12;
int led2 = 11;
int led3 =10;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led, LOW); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led3, HIGH); // turn the LED off by making the voltage LOW
delay(200); // wait for a second // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led3, LOW); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led, HIGH); // turn the LED off by making the voltage LOW
delay(200); // wait for a second // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led2, LOW); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led3, HIGH); // turn the LED off by making the voltage LOW
delay(200); // wait for a second // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led, LOW); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led, HIGH); // turn the LED off by making the voltage LOW
delay(200); // wait for a second // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led4, HIGH); // turn the LED off by making the voltage LOW
delay(200); // wait for a second // wait for a second
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500);
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(500);
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second // wait for a second
}
- Para que hubiera 4 leds con un patrón. Código:
*/
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 12;
int led2 = 11;
int led3 =10;
int led4 = 9;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led, LOW); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led3, HIGH); // turn the LED off by making the voltage LOW
delay(200); // wait for a second // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led4, HIGH); // turn the LED off by making the voltage LOW
delay(200); // wait for a second // wait for a second
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led3, LOW); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led, HIGH); // turn the LED off by making the voltage LOW
delay(200); // wait for a second // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led4, HIGH); // turn the LED off by making the voltage LOW
delay(200); // wait for a second // wait for a second
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led2, LOW); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led3, HIGH); // turn the LED off by making the voltage LOW
delay(200); // wait for a second // wait for a second
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led4, HIGH); // turn the LED off by making the voltage LOW
delay(200); // wait for a second // wait for a second
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led, LOW); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200);
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led, HIGH); // turn the LED off by making the voltage LOW
delay(200); // wait for a second // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led4, HIGH); // turn the LED off by making the voltage LOW
delay(200); // wait for a second // wait for a second
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
delay(200);
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500);
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500);
digitalWrite(led3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500);
digitalWrite(led4, HIGH); // turn the LED off by making the voltage LOW
delay(500);
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second // wait for a second
digitalWrite(led2, LOW); // turn the LED off by making the voltage LOW
delay(500);
digitalWrite(led3, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second // wait for a second
digitalWrite(led4, LOW); // turn the LED off by making the voltage LOW
delay(500);
}