Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Arduino Sketch for Blinking Strands of LEDs
// Set which pin each strand of lights is connected to
int lightStrand1 = A4;
int lightStrand2 = 3;
// Runs once
void setup() {
// Set strands as outputs
pinMode(lightStrand1, OUTPUT);
pinMode(lightStrand2, OUTPUT);
// Initialize Serial, set the baud rate to 9600 bps
Serial.begin(9600);
}
void loop() {
// Pauses the loop for 1.5 seconds
delay(1500); // milliseconds
// Setting lightStrand1 to HIGH turns ON the LEDs connected to pin A4
// Setting lightStrand2 to LOW turns OFF the LEDs connected to pin 3
digitalWrite(lightStrand1, HIGH);
digitalWrite(lightStrand2, LOW);
// Pauses the loop for 1.5 seconds
delay(1500); // milliseconds
// Setting lightStrand1 to LOW turns OFF the LEDs connected to pin A4
// Setting lightStrand2 to HIGH turns ON the LEDs connected to pin 3
digitalWrite(lightStrand1, LOW);
digitalWrite(lightStrand2, HIGH);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment