Untitled
unknown
plain_text
a year ago
1.3 kB
16
Indexable
#define redPin 10
#define bluePin 9
void setup() {
// put setup code here, to run once:
pinMode(redPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop() {
// put main code here, to run repeatedly:
blinkLED(redPin, 5, 50); //Turn ON OFF RED LED
delay(100);
blinkLED(bluePin, 5, 50); //TURN ON OFF BLUE LED
delay(100);
blinkAll(redPin, bluePin, 5, 50);
delay(100);
}
// LED BLINKING FUNCTION
void blinkLED(int pin, int numOfBlinks, int blinkDelay) {
for (int i = 0; i < numOfBlinks; i++) {
digitalWrite(pin, HIGH); // Turn the Blue LED on
delay(blinkDelay); // Wait for the specified delay
digitalWrite(pin, LOW); // Turn the Blue LED off
delay(blinkDelay); // Wait for the specified delay
}
}
void blinkAll(int pin1, int pin2, int numOfBlinks, int blinkDelay) {
for (int i = 0; i < numOfBlinks; i++) {
digitalWrite(pin1, HIGH); // Turn the Blue LED on
digitalWrite(pin2, HIGH); // Turn the Blue LED on
delay(blinkDelay); // Wait for the specified delay
digitalWrite(pin1, LOW); // Turn the Blue LED off
digitalWrite(pin2, LOW); // Turn the Blue LED off
delay(blinkDelay); // Wait for the specified delay
}
}
Editor is loading...
Leave a Comment