#include <Adafruit_NeoPixel.h>
// Which pin on the Arduino is connected to the NeoPixels?
#define PIN 7// On Trinket or Gemma, suggest changing this to 1
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 70 // Popular NeoPixel ring size
// When setting up the NeoPixel library, we tell it how many pixels,
// and which pin to use to send signals. Note that for older NeoPixel
// strips you might need to change the third parameter -- see the
// strandtest example for more information on possible values.
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int subsets[10] = {0b00111111,0b00001100,0b01110110,0b01011110,0b01001101,0b01011011,0b01111011,0b00001110,0b01111111,0b01011111};
uint8_t number;
void setup() {
//delay(3000); // 3 second delay for recovery
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
pixels.setBrightness(75);
pixels.clear(); // Set all pixel colors to 'off'
}
void test_digit(uint8_t digit)
{
int offset = 0;
for (int b=0;b<8;b++)
{
if (subsets[digit]&(1<<b))
{
for (int i=0;i<5;i++)
{
pixels.setPixelColor(i+offset, 0x0000FF00);
}
}
offset=offset+5;
}
}
void top_shift(uint8_t digit,uint8_t step,uint8_t soffset, Adafruit_NeoPixel * strip, uint32_t color)
{
if (step==0)
{
if (subsets[digit]&(1<<4))
{
for (int j=0;j<5;j++)
{
strip->setPixelColor(j+5+soffset, color);
}
}
}
if (step>0 && step<6)
{
if (subsets[digit]&(1<<1))
{
for (int j=0;j<5;j++)
{
strip->setPixelColor(j+5+soffset, color);
}
}
if (subsets[digit]&(1<<0))
{
for (int j=0;j<step;j++)
{
strip->setPixelColor(j+0+soffset, color);
}
}
if (subsets[digit]&(1<<2))
{
for (int j=0;j<step;j++)
{
strip->setPixelColor(j+10+(5-step)+soffset, color);
}
}
}
if (step==6)
{
if (subsets[digit]&(1<<1))
{
for (int j=0;j<5;j++)
{
strip->setPixelColor(j+5+soffset, color);
}
}
if (subsets[digit]&(1<<0))
{
for (int j=0;j<5;j++)
{
strip->setPixelColor(j+0+soffset, color);
}
}
if (subsets[digit]&(1<<2))
{
for (int j=0;j<5;j++)
{
strip->setPixelColor(j+10+soffset, color);
}
}
if (subsets[digit]&(1<<6))
{
for (int j=0;j<5;j++)
{
strip->setPixelColor(j+30+soffset, color);
}
}
}
if (step>6 && step<12)
{
if (subsets[digit]&(1<<1))
{
for (int j=0;j<5;j++)
{
strip->setPixelColor(j+5+soffset, color);
}
}
if (subsets[digit]&(1<<6))
{
for (int j=0;j<5;j++)
{
strip->setPixelColor(j+30+soffset, color);
}
}
if (subsets[digit]&(1<<0))
{
for (int j=0;j<5;j++)
{
strip->setPixelColor(j+0+soffset, color);
}
}
if (subsets[digit]&(1<<2))
{
for (int j=0;j<5;j++)
{
strip->setPixelColor(j+10+soffset, color);
}
}
if (subsets[digit]&(1<<5))
{
for (int j=0;j<step-6;j++)
{
strip->setPixelColor(j+25+soffset, color);
}
}
if (subsets[digit]&(1<<3))
{
for (int j=0;j<step-6;j++)
{
strip->setPixelColor(j+15+(11-step)+soffset, color);
}
}
}
if (step==12)
{
for (int b=0;b<8;b++)
{
if (subsets[digit]&(1<<b))
{
for (int j=0;j<5;j++)
{
strip->setPixelColor(j+b*5+soffset, color);
}
}
}
}
}
void loop()
{
// Call the current pattern function once, updating the 'leds' array
//test_digit(number);
pixels.clear();
pixels.show();
delay(200);
for (int i=0;i<13;i++)
{
pixels.fill(0,0,35);
pixels.fill(0,35,35);
top_shift(number,i,0,&pixels,0x0000FF00);
top_shift(number,i,35,&pixels,0x0000FF00);
pixels.show();
delay(20);
}
pixels.show();
delay((1000));
number++;
pixels.clear();
if(number==10) number=0;
}