0% found this document useful (0 votes)
10 views6 pages

Actividad Con For

Uploaded by

perr1
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)
10 views6 pages

Actividad Con For

Uploaded by

perr1
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/ 6

E

COLEGIO JUÁREZ

Tecnologías de la Información y
Comunicación
MTRO. Moisés Manuel Ruiz Bravo

Actividad con For

Gerardo Emilio Avendaño García

ASUNCIÓN NOCHIXTLÁN 3 DE DICIEMBRE DE 2024


Código :
int ledR = 9;

int ledG = 10;

int ledB = 11;

String led;

int dt = 300;

void setup() {

Serial.begin(9600);

pinMode(ledR, OUTPUT);

pinMode(ledG, OUTPUT);

pinMode(ledB, OUTPUT);

void loop() {

Serial.println("Escriba el led que quiera que se comporte como una velita");

while (Serial.available() == 0) {

led = Serial.readString();

led.trim();

if (led == "Primero") {

for (int a = 0 ; a < 5 ; a++) {

analogWrite(ledR, random(100)+50);

delay(dt);

digitalWrite(ledR, LOW);

analogWrite(ledR, random(75)+80);

delay(dt);

digitalWrite(ledR, LOW);
analogWrite(ledR,random(60)+140);

delay(dt);

digitalWrite(ledR,LOW);

Serial.println("Primer led ciclo 5");

if (led == "Segundo") {

for (int b = 0 ; b < 7 ; b++) {

analogWrite(ledG, random(100)+50);

delay(dt);

digitalWrite(ledG, LOW);

analogWrite(ledG, random(75)+80);

delay(dt);

digitalWrite(ledG, LOW);

analogWrite(ledG,random(60)+140);

delay(dt);

digitalWrite(ledG,LOW);

Serial.println("Segundo led ciclo 7");

if (led == "Tercero") {

for (int c = 0 ; c < 8 ; c++) {

analogWrite(ledB, random(100)+50);

delay(dt);

digitalWrite(ledB, LOW);

analogWrite(ledB, random(75)+80);

delay(dt);
digitalWrite(ledB, LOW);

analogWrite(ledB,random(60)+140);

delay(dt);

digitalWrite(ledB,LOW);

Serial.println("Tercer led ciclo 8");

Protoboard y Arduino:

You might also like