0% found this document useful (0 votes)
21 views7 pages

pc1 Uc Córdova

The document describes code for an Arduino program to control an RGB LED and a traffic light simulation. The RGB LED code uses nested for loops to cycle through all possible RGB color combinations. The traffic light simulation code uses digitalWrite to turn on/off LEDs connected to pins to simulate a traffic light changing between red, yellow, and green lights.

Uploaded by

Branco Córdova
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views7 pages

pc1 Uc Córdova

The document describes code for an Arduino program to control an RGB LED and a traffic light simulation. The RGB LED code uses nested for loops to cycle through all possible RGB color combinations. The traffic light simulation code uses digitalWrite to turn on/off LEDs connected to pins to simulate a traffic light changing between red, yellow, and green lights.

Uploaded by

Branco Córdova
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

ALUMNO: CÓRDOVA FUENTES, BRANCO MARCO

U21306636

SEMÁFORO:
int r = 6;

int a = 7;

int verde = 8;
void setup()

pinMode (r, OUTPUT);

pinMode (a, OUTPUT);

pinMode (verde, OUTPUT);

void loop ()

digitalWrite(verde,LOW); //inician los leds apagados

digitalWrite(a,LOW);

digitalWrite(r,LOW);

delay(100);

while (1) //bucle infinito

//rojo

digitalWrite(verde,HIGH);

delay(400);

digitalWrite(verde,LOW);

delay(1000);

digitalWrite(verde,HIGH);

delay(400);

digitalWrite(verde,LOW);

delay(1000);

digitalWrite(verde,HIGH);

delay(400);

digitalWrite(verde,LOW);

delay(1000);

digitalWrite(verde,HIGH);//led verde prendido por 5 segundos


delay(5000);

digitalWrite(verde,LOW);

delay(1000);

digitalWrite(verde,HIGH);

delay(400);

digitalWrite(verde,LOW);

delay(1000);

digitalWrite(verde,HIGH);

delay(400);

digitalWrite(verde,LOW);

delay(1000);

digitalWrite(verde,HIGH);

delay(400);

digitalWrite(verde,LOW);

delay(1000);

//amarillo

digitalWrite(a,HIGH);

delay(400);

digitalWrite(a,LOW);

delay(1000);

digitalWrite(a,HIGH); //led amarillo prendido por 3 segundos

delay(3000);

digitalWrite(a,LOW);

delay(1000);

digitalWrite(a,HIGH);

delay(400);

digitalWrite(a,LOW);

delay(1000);

//rojo

digitalWrite(r,HIGH);

delay(400);
digitalWrite(r,LOW);

delay(1000);

digitalWrite(r,HIGH);

delay(400);

digitalWrite(r,LOW);

delay(1000);

digitalWrite(r,HIGH);

delay(400);

digitalWrite(r,LOW);

delay(1000);

digitalWrite(r,HIGH); //led rojo prendido por 5 segundos

delay(5000);

digitalWrite(r,LOW);

delay(1000);

digitalWrite(r,HIGH);

delay(400);

digitalWrite(r,LOW);

delay(1000);

digitalWrite(r,HIGH);

delay(400);

digitalWrite(r,LOW);

delay(1000);

digitalWrite(r,HIGH);

delay(400);

digitalWrite(r,LOW);

delay(1000);

}
DIODO RGB:
int r = 9;

int g = 10;

int b = 11;

int cont1;

int cont2;

int cont3;

void setup()

pinMode (r, OUTPUT);

pinMode (g, OUTPUT);

pinMode (b, OUTPUT);

void loop()

for(cont3 = 0; cont3<255; cont3++)

for(int cont2 = 0; cont2<255; cont2++)

for(int cont1 = 0; cont1<255; cont1++)

analogWrite(r,cont1);

analogWrite(g,cont2);

analogWrite(b,cont3);

delay(1);

You might also like