Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Adafruit_NeoPixel.h>
- #ifdef __AVR__
- #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
- #endif
- #define PIN 6
- #define NUMPIXELS 5
- Adafruit_NeoPixel strip(NUMPIXELS, PIN, NEO_GRBW + NEO_KHZ800);
- int buttonPin1 = 11;
- int buttonPin2 = 3;
- int buttonState1 = 0;
- int buttonState2 = 0;
- //initializing buttons and neopixel strip
- void setup() {
- // put your setup code here, to run once:
- pinMode(buttonPin1,INPUT_PULLUP);
- pinMode(buttonPin2, INPUT_PULLUP);
- strip.begin();
- Serial.begin(9600);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- //Last and first one are the only ones that turn the color they are suppossed to
- // Serial.println(buttonState);
- buttonState1 = digitalRead(buttonPin1);
- buttonState2 = digitalRead(buttonPin2);
- Serial.println(buttonState2);
- if(buttonState1 == HIGH && buttonState2 == LOW)
- {
- //after trial and error I figured out that these were the values that corresponded to red
- //even though I'm pretty sure that (255, 0, 0) does
- // strip.setPixelColor(0, strip.Color(255,0,0));
- // strip.setPixelColor(3, strip.Color(255,0,0));
- // //strip.setPixelColor(1, strip.Color(0, 0,255)); Corresponds to green on 3rd pixel
- // strip.setPixelColor(2, strip.Color(0,0,255));
- // strip.setPixelColor(1, strip.Color(0, 255,0));
- // strip.show();
- for(int i = 0; i < strip.numPixels(); i++)
- {
- strip.setPixelColor(i, strip.Color(0,150,100)); //should have been a blue teal color
- strip.show();
- delay(25);
- }
- }
- else if(buttonState1 == LOW && buttonState2 == HIGH)
- {
- for(int i = 0; i < strip.numPixels(); i++)
- {
- strip.setPixelColor(i, strip.Color(255,0, 0)); //makes it many colors? should be red
- strip.show();
- delay(20);
- }
- }
- else if(buttonState1 == HIGH && buttonState2 == HIGH){
- for(uint16_t i = 0; i < strip.numPixels();i++){
- strip.setPixelColor(i, strip.Color(255,255,255)); //they should have all been white
- strip.show();
- delay(25);
- }
- }
- else if(buttonState1 == LOW && buttonState2 == LOW) //this just makes it so when neither button is pressed down there are no lights
- {
- strip.clear();
- strip.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement