SHARE
TWEET

Untitled

a guest Oct 13th, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Adafruit_NeoPixel.h>
  2. #ifdef __AVR__
  3.  #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
  4. #endif
  5.  
  6. #define PIN 6
  7. #define NUMPIXELS 5
  8. Adafruit_NeoPixel strip(NUMPIXELS, PIN, NEO_GRBW + NEO_KHZ800);
  9.  
  10. int buttonPin1 = 11;
  11. int buttonPin2 = 3;                                                                                                                                                                                                                                      
  12. int buttonState1 = 0;
  13. int buttonState2 = 0;
  14.  
  15. //initializing buttons and neopixel strip
  16. void setup() {
  17.   // put your setup code here, to run once:
  18.   pinMode(buttonPin1,INPUT_PULLUP);
  19.   pinMode(buttonPin2, INPUT_PULLUP);
  20.   strip.begin();
  21.  
  22.   Serial.begin(9600);
  23. }
  24.  
  25. void loop() {
  26.   // put your main code here, to run repeatedly:
  27.  
  28.   //Last and first one are the only ones that turn the color they are suppossed to
  29.  
  30.   //  Serial.println(buttonState);
  31.   buttonState1 = digitalRead(buttonPin1);
  32.   buttonState2 = digitalRead(buttonPin2);
  33.   Serial.println(buttonState2);
  34.  
  35.   if(buttonState1 == HIGH && buttonState2 == LOW)
  36.   {
  37.       //after trial and error I figured out that these were the values that corresponded to red
  38.       //even though I'm pretty sure that (255, 0, 0) does
  39. //      strip.setPixelColor(0, strip.Color(255,0,0));
  40. //      strip.setPixelColor(3, strip.Color(255,0,0));
  41. //      //strip.setPixelColor(1, strip.Color(0, 0,255)); Corresponds to green on 3rd pixel
  42. //      strip.setPixelColor(2, strip.Color(0,0,255));
  43. //      strip.setPixelColor(1, strip.Color(0, 255,0));
  44. //      strip.show();
  45.  
  46.       for(int i = 0; i < strip.numPixels(); i++)
  47.       {
  48.         strip.setPixelColor(i, strip.Color(0,150,100)); //should have been a blue teal color
  49.         strip.show();
  50.         delay(25);
  51.       }
  52.   }
  53.   else if(buttonState1 == LOW && buttonState2 == HIGH)
  54.   {
  55.     for(int i = 0; i < strip.numPixels(); i++)
  56.     {
  57.       strip.setPixelColor(i, strip.Color(255,0, 0)); //makes it many colors? should be red
  58.       strip.show();
  59.       delay(20);
  60.     }
  61.   }
  62.   else if(buttonState1 == HIGH && buttonState2 == HIGH){
  63.     for(uint16_t i = 0; i < strip.numPixels();i++){
  64.       strip.setPixelColor(i, strip.Color(255,255,255)); //they should have all been white
  65.       strip.show();
  66.       delay(25);
  67.     }
  68.   }
  69. else if(buttonState1 == LOW && buttonState2 == LOW) //this just makes it so when neither button is pressed down there are no lights
  70.  {
  71.    strip.clear();
  72.    strip.show();
  73.  }
  74.  
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top