Last active
June 12, 2016 20:45
-
-
Save jgillick/b5222daac840fb1913df305137d49a61 to your computer and use it in GitHub Desktop.
Intro to Arduino and Blinky Lights
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 <Adafruit_NeoPixel.h> | |
// Constant values | |
#define DATA_PIN 6 | |
#define NUM_LEDS 32 | |
// Load NeoPixel library | |
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, DATA_PIN, NEO_GRB + NEO_KHZ800); | |
// Set color variables | |
int colorChoose = 0; | |
int red = 255; | |
int green = 0; | |
int blue = 0; | |
void setup() { | |
// Initialize led strip | |
strip.begin(); | |
strip.show(); | |
} | |
void loop() { | |
// Loop over each LED | |
for (int i = 0; i < NUM_LEDS; i++) { | |
strip.setPixelColor(i, red, green, blue); | |
strip.show(); | |
delay(20); | |
} | |
// Change the color for the next iteration | |
colorChoose++; | |
if (colorChoose == 1) { | |
red = 0; | |
green = 255; | |
blue = 0; | |
} | |
else if (colorChoose == 2) { | |
red = 0; | |
green = 0; | |
blue = 255; | |
} | |
else if (colorChoose == 3) { | |
red = 255; | |
green = 0; | |
blue = 0; | |
colorChoose = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment