Skip to content

Instantly share code, notes, and snippets.

@dcbriccetti
Created March 25, 2022 03:12
Show Gist options
  • Save dcbriccetti/6f407ac22f0a5095c5f03b368395da48 to your computer and use it in GitHub Desktop.
Save dcbriccetti/6f407ac22f0a5095c5f03b368395da48 to your computer and use it in GitHub Desktop.
Fun with Relays
#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