Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. /*Cameron Saunders
  2. * Digital Futures
  3. * NeoPixel In Class Assignment
  4. * Date: 2019-11-13
  5. */
  6.  
  7. #include <Adafruit_NeoPixel.h>
  8. #ifdef __AVR__
  9. #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
  10. #endif
  11.  
  12. // Which pin on the Arduino is connected to the NeoPixels?
  13. #define LED_PIN 6
  14.  
  15. // How many NeoPixels are attached to the Arduino?
  16. #define LED_COUNT 60
  17.  
  18. // Declare NeoPixel strip:
  19. Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
  20.  
  21. void setup() {
  22. // put your setup code here, to run once:
  23. pinMode (13, INPUT);
  24. strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
  25. strip.show(); // Turn OFF all pixels ASAP
  26. strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
  27. }
  28.  
  29. void loop() {
  30. if (digitalRead(13) == HIGH) {
  31. colorWipe(strip.Color(0, 255, 255), 50);
  32. colorWipe(strip.Color( 255, 255, 0), 50);
  33. colorWipe(strip.Color( 0, 0, 255), 50);
  34. } else {
  35.  
  36. colorWipe(strip.Color( 0, 0, 255), 50);
  37. }
  38. }
  39.  
  40. void colorWipe(uint32_t color, int wait) {
  41. for (int i = 0; i < strip.numPixels(); i++) {
  42. strip.setPixelColor(i, color);
  43. strip.show();
  44. delay(wait);
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement