#include <Adafruit_NeoPixel.h>
#define LED_PIN 6
#define NUM_LEDS 16
int spin=0;
int i= 0;
int randNumber = random(0,16);
int pos;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
}
void loop() {
roulette(strip.Color(250,0,0),strip.Color(0,250,0),strip.Color(0,0,250));
} /*****************END VOID*******************/
void roulette(uint32_t c, uint32_t d, uint32_t e)
{
float wait = 20.0;
if (spin <20 ) {
colorWipe(c,d,e, wait);
}
else
if (spin>20) {
for ( int i = 0; i <(16*6)+randNumber; i++)
{
colorWipe(c,d,e, wait);
wait = (wait * 2.046);
}
}
}
/*
void advanceOne(uint32_t c,uint32_t d,uint32_t e, float wait) {
clr();//Clear the display
if ((pos & 0x01) == 0) { //check to see if position is an even number
strip.setPixelColor(pos, c); //turn on the pixel at position 'pos'
} else //else it is odd
{strip.setPixelColor(pos, d);
}
if (pos == 0) { //or check to see if it is '0'
strip.setPixelColor(pos, e);
}
strip.show();
delay(wait);
if (dir){ //if direction var is set to clockwise
pos--; //decrement the position
if(pos<0) {pos=15;} //resets running count if < 0}
}
else{
pos++; //increment the position
if(pos>15) {pos=0;} //resets running count if > 15}
}
}//end advanceOne function
//clears the display
void clr(){
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, 0);
strip.show();
}
}
*/
void colorWipe(uint32_t c, uint32_t d, uint32_t e, float wait) {
for(i=0; i<=strip.numPixels(); i++) {
strip.setPixelColor(i, d);
strip.setPixelColor(i-1, 0);
if(i==16) strip.setPixelColor(15, (0,0,0));
strip.show();
delay(wait);
spin++;
}
}