#include <Arduino.h>
#include <Adafruit_NeoPixel.h>
#define BTN 3
#define PIN 4
#define NUMPIXELS 1
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 500;
int i = 0;
int mode = 0;
//#define WHITE pixel.Color(255, 255, 255)
//#define RED pixel.Color(255, 0, 0)
//#define GREEN pixel.Color(0, 255, 0)
//#define BLUE pixel.Color(0, 0, 255)
void setup() {
pixels.begin();
pinMode(BTN, INPUT);
randomSeed(analogRead(0));
}
void loop() {
// put your main code here, to run repeatedly:
if(BTN == LOW){
i++;
mode = i;
if(i > 4){
i = 0;
}
if(mode == 0){
pixels.setPixelColor(1, pixels.Color(255, 255, 255));
}
if(mode == 1){
pixels.setPixelColor(1, pixels.Color(255, 0, 0));
}
if(mode == 2){
pixels.setPixelColor(1, pixels.Color(0, 255, 0));
}
if(mode == 3){
pixels.setPixelColor(1, pixels.Color(0, 0, 255));
}
pixels.show();
if(mode == 4){
int r = random(128);
int g = random(128);
int b = random(128);
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(r,g,b));
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
}
//setMode(i);
}
}
void setMode(uint8_t mode){
}