Tareas Arduino 2, 3 y 4

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

Tarea # 2

#include <Servo.h>

Servo Motor;

Int timer = 10;

Void setup(){

Motor .attach(9);

For(int pin =2;pin<=6;pin ++)

pinMode(pin,OUTPUT);

Void loop() {

For(int i =0;i<=180;i ++)

Motor.write(i);

Delay(timer);

// secuencia de led

For(int led =2;led<=5;led ++)

digitalWrite(led,1);

delay(1000);

digitalWrite(led,0);

delay(1000);

}
//Sonido

Tone(6,380);

Delay(3000);

noTone(6);

for(int i =179;i>=0;i --)

Motor.write(i);

Delay(timer);

}
Tarea # 3

Int LEDRNS=2;

Int LEDANS=3;

Int LEDVNS=4;

Int LEDRSN=5;

Int LEDASN=6;

Int LEDVSN=7;

Int LEDREO=8;

Int LEDAEO=9;

Int LEDVEO=10;

Int LEDROE=11;

Int LEDAOE=12;

Int LEDVOE=13;

Void setup ()

pinMode(2, OUTPUT);

pinMode(3, OUTPUT);

pinMode(4, OUTPUT);

pinMode(5, OUTPUT);

pinMode(6, OUTPUT);

pinMode(7, OUTPUT);

pinMode(8, OUTPUT);

pinMode(9, OUTPUT);

pinMode(10, OUTPUT);

pinMode(11, OUTPUT);

pinMode(12, OUTPUT);
pinMode(13, OUTPUT);

Void loop()

digitalWrite(4, HIGH);//verde N-S

digitalWrite(5, HIGH);//rojo S-N

digitalWrite(8, HIGH);//rojo E-O

digitalWrite(11, HIGH);//rojo O-E

delay(8000);

digitalWrite(4, LOW);//VERDE N-S INTERMITENTE POR 1 SEGUNDO

delay(1000);

digitalWrite(4, HIGH);//VERDE N-S INTERMITENTE POR 1 SEGUNDO

delay(1000);

digitalWrite(4, LOW);//VERDE N-S INTERMITENTE POR 1 SEGUNDO

delay(1000);

digitalWrite(3, HIGH);//LUZ AMARRILLA POR 3 SEGUNDOS

delay(3000);

digitalWrite(3, LOW);//LUZ AMRILLA SE APAGA N-S

digitalWrite(2, HIGH);//ROJO N-S Y LE CEDE LUZ VERDE S-N

digitalWrite(7, HIGH);//VERDE S-N

digitalWrite(5, LOW);//ROJO S-N POR 6 SEGUNDOS

delay(8000);//

digitalWrite(7, LOW);//VERDE S-N INTERMITENTE

delay(1000);

digitalWrite(7, HIGH);//VERDE S-N INTERMITENTE

delay(1000);

digitalWrite(7, LOW);//VERDE S-N INTERMITENTE


delay(1000);

digitalWrite(6, HIGH);//AMARILLO S-N

delay(3000);

digitalWrite(6, LOW);// SE APAGA AMARILLO S-N

digitalWrite(5, HIGH);//ROJO S-N Y LE CEDE LUZ VERDE E-O

digitalWrite(10, HIGH);//VERDE E-O

digitalWrite(8, LOW);//ROJO E-O

delay(8000);//

digitalWrite(10, LOW);//INTERMITENTE VERDE E-O

delay(1000);

digitalWrite(10, HIGH);//INTERMITENTE VERDE E-O

delay(1000);

digitalWrite(10, LOW);//INTERMITENTE VERDE E-O

delay(1000);

digitalWrite(9, HIGH);//AMARILLO E-O

delay(3000);

digitalWrite(9, LOW);//SE APAGA AMARILLO E-O

digitalWrite(8, HIGH);//ROJO E-O Y CEDE LUZ VERDE O-E

digitalWrite(13, HIGH);//VERDE O-E

digitalWrite(11, LOW);//ROJO O-E

delay(8000);//

digitalWrite(13, LOW);//INTERMITENTE VERDE O-E

delay(1000);//

digitalWrite(13, HIGH);//INTERMITENTE VERDE O-E

delay(1000);//

digitalWrite(13, LOW);//INTERMITENTE VERDE O-E

delay(1000);//
digitalWrite(12, HIGH);//AMARILLO O-E

delay(3000);//

Tarea # 4

Int BUTTON1=2;

Int BUTTON2=3;

Int BUTTON3=4;

Int LED1=5;
Int LED2=6;

Int LED3=7;

Int LED4=8;

Int LED5=9;

Int LED6=10;

Int LED7=11;

Int LED8=12;

Void setup ()

pinMode(2, INPUT);

pinMode(3, INPUT);

pinMode(4, INPUT);

pinMode(5, OUTPUT);

pinMode(6, OUTPUT);

pinMode(7, OUTPUT);

pinMode(8, OUTPUT);

pinMode(9, OUTPUT);

pinMode(10, OUTPUT);

pinMode(11, OUTPUT);

pinMode(12, OUTPUT);

Void loop()

If(digitalRead(2)==LOW)

digitalWrite(12, HIGH);

delay(1000);
digitalWrite(12, LOW);

digitalWrite(11, HIGH);

delay(1000);

digitalWrite(11, LOW);

digitalWrite(10, HIGH);

delay(1000);

digitalWrite(10, LOW);

digitalWrite(9, HIGH);

delay(1000);

digitalWrite(9, LOW);

If(digitalRead(3)==LOW)

digitalWrite(8, HIGH);

delay(1000);

digitalWrite(8, LOW);

digitalWrite(7, HIGH);

delay(1000);

digitalWrite(7, LOW);

digitalWrite(6, HIGH);

delay(1000);

digitalWrite(6, LOW);

digitalWrite(5, HIGH);

delay(1000);

digitalWrite(5, LOW);

If(digitalRead(4)==LOW)
{

digitalWrite(5, HIGH);

digitalWrite(6, HIGH);

digitalWrite(7, HIGH);

digitalWrite(8, HIGH);

digitalWrite(9, HIGH);

digitalWrite(10, HIGH);

digitalWrite(11, HIGH);

digitalWrite(12, HIGH);

delay(1000);

digitalWrite(5, LOW);

digitalWrite(6, LOW);

digitalWrite(7, LOW);

digitalWrite(8, LOW);

digitalWrite(9, LOW);

digitalWrite(10, LOW);

digitalWrite(11, LOW);

digitalWrite(12, LOW);

delay(1000);

digitalWrite(5, HIGH);

digitalWrite(6, HIGH);

digitalWrite(7, HIGH);

digitalWrite(8, HIGH);

digitalWrite(9, HIGH);

digitalWrite(10, HIGH);

digitalWrite(11, HIGH);

digitalWrite(12, HIGH);
delay(1000);

digitalWrite(5, LOW);

digitalWrite(6, LOW);

digitalWrite(7, LOW);

digitalWrite(8, LOW);

digitalWrite(9, LOW);

digitalWrite(10, LOW);

digitalWrite(11, LOW);

digitalWrite(12, LOW);

delay(1000);

}}

You might also like