Created
March 25, 2022 03:12
-
-
Save dcbriccetti/6f407ac22f0a5095c5f03b368395da48 to your computer and use it in GitHub Desktop.
Fun with Relays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
int pins[] = {2, 3, 4, 5}; | |
int numPins = sizeof pins / sizeof pins[0]; | |
void setup() { | |
for (int i = 0; i < numPins; ++i) | |
pinMode(pins[i], OUTPUT); | |
} | |
int del = 120; | |
int pinIndex = 0; | |
void loop() { | |
int pin = pins[pinIndex]; | |
pinIndex = (pinIndex + 1) % numPins; | |
digitalWrite(pin, HIGH); | |
delay(del); | |
digitalWrite(pin, LOW); | |
delay(del); | |
if (del > 10) | |
--del; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment