Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Cameron Saunders
- * Digital Futures
- * NeoPixel In Class Assignment
- * Date: 2019-11-13
- */
- #include <Adafruit_NeoPixel.h>
- #ifdef __AVR__
- #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
- #endif
- // Which pin on the Arduino is connected to the NeoPixels?
- #define LED_PIN 6
- // How many NeoPixels are attached to the Arduino?
- #define LED_COUNT 60
- // Declare NeoPixel strip:
- Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
- void setup() {
- // put your setup code here, to run once:
- pinMode (13, INPUT);
- strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
- strip.show(); // Turn OFF all pixels ASAP
- strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
- }
- void loop() {
- if (digitalRead(13) == HIGH) {
- colorWipe(strip.Color(0, 255, 255), 50);
- colorWipe(strip.Color( 255, 255, 0), 50);
- colorWipe(strip.Color( 0, 0, 255), 50);
- } else {
- colorWipe(strip.Color( 0, 0, 255), 50);
- }
- }
- void colorWipe(uint32_t color, int wait) {
- for (int i = 0; i < strip.numPixels(); i++) {
- strip.setPixelColor(i, color);
- strip.show();
- delay(wait);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement