0% found this document useful (0 votes)
9 views1 page

Multitasking Usando Delay - Ino

This document contains an Arduino code that controls two LEDs and reads a button input. The code increments two counters and toggles the blue LED every 100 iterations and the red LED every 50 iterations. It also prints the button state to the serial monitor.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

Multitasking Usando Delay - Ino

This document contains an Arduino code that controls two LEDs and reads a button input. The code increments two counters and toggles the blue LED every 100 iterations and the red LED every 50 iterations. It also prints the button state to the serial monitor.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

/*

Coded by cefuve 2021


Webpage: https://www.cefuve.com
Youtube: https://www.youtube.com/user/cefuve
Instagram: https://www.instagram.com/cefuve_electronics/
Facebook: https://www.facebook.com/cefuve.electronics
*/

#define pinLED 2
#define pinBtn 6
#define pinLEDred A5
int count = 0;
int count2 = 0;

void setup() {
Serial.begin(9600);
pinMode(pinLED, OUTPUT);
pinMode(pinLEDred, OUTPUT);
pinMode(pinBtn, INPUT_PULLUP);
}

void loop() {
count++;
count2++;
delay(10);

lecturaBtn();

if(count == 100){
ledAzul();
}

if(count2 == 50){
ledRojo();
}
}

void lecturaBtn(){
int lectura = digitalRead(pinBtn);
Serial.println(lectura);
}

void ledAzul(){
int estadoLED = digitalRead(pinLED);
digitalWrite(pinLED, !estadoLED);
count = 0;
}

void ledRojo(){
int estadoLED = digitalRead(pinLEDred);
digitalWrite(pinLEDred, !estadoLED);
count2 = 0;
}

You might also like