#include <binary.h>
#include <LedControl.h>
int DIN = 12;
int CS = 10;
int CLK = 11;
LedControl lc = LedControl(DIN, CLK, CS, 0);
int BG_value0 = B00000001; //bottom segment DIG 0
int BG_value1 = B00000001; //bottom segment DIG 1
int BG_value2 = B00000001; //bottom segment DIG 2
int BG_value3 = B00000001; //bottom segment DIG 3
int BG_value4 = B00000001; //bottom segment DIG 4
int BG_value5 = B00000001; //bottom segment DIG 5
int BG_value6 = B00000001; //bottom segment DIG 6
int BG_counter = 1;
byte BG_top = 8; //total segments per digit
byte BG_total = 51; //total segments used
byte BG_digit = 0;
void setup()
{
lc.shutdown(0,false); // turn off power saving, enables display
lc.setIntensity(0,12); // sets brightness (0~15 possible values)
lc.clearDisplay(0); // clear screen
}
void loop()
{
BG_digit = (BG_counter - 1) / BG_top; //determine digit
if (BG_digit == 0 && BG_counter <= 8) //digit 0
{
lc.setRow(0,BG_digit,BG_value0);
BG_value0 = (BG_value0 << 1)|1;
BG_counter++;
}
if (BG_digit == 1 && BG_counter <= 16) //digit 0+1
{
lc.setRow(0,0,B11111111);
lc.setRow(0,BG_digit,BG_value1);
BG_value1 = (BG_value1 << 1)|1;
BG_counter++;
}
if (BG_digit == 2 && BG_counter <= 24) //digit 0+1+2
{
lc.setRow(0,0,B11111111);
lc.setRow(0,1,B11111111);
lc.setRow(0,BG_digit,BG_value2);
BG_value2 = (BG_value2 << 1)|1;
BG_counter++;
}
if (BG_digit == 3 && BG_counter <= 32) //digit 0+1+2+3
{
lc.setRow(0,0,B11111111);
lc.setRow(0,1,B11111111);
lc.setRow(0,2,B11111111);
lc.setRow(0,BG_digit,BG_value3);
BG_value3 = (BG_value3 << 1)|1;
BG_counter++;
}
if (BG_digit == 4 && BG_counter <= 40) //digit 0+1+2+3+4
{
lc.setRow(0,0,B11111111);
lc.setRow(0,1,B11111111);
lc.setRow(0,2,B11111111);
lc.setRow(0,3,B11111111);
lc.setRow(0,BG_digit,BG_value4);
BG_value4 = (BG_value4 << 1)|1;
BG_counter++;
}
if (BG_digit == 5 && BG_counter <= 48) //digit 0+1+2+3+4+5
{
lc.setRow(0,0,B11111111);
lc.setRow(0,1,B11111111);
lc.setRow(0,2,B11111111);
lc.setRow(0,3,B11111111);
lc.setRow(0,4,B11111111);
lc.setRow(0,BG_digit,BG_value5);
BG_value5 = (BG_value5 << 1)|1;
BG_counter++;
}
if (BG_digit == 6 && BG_counter <= BG_total) //digit 0+1+2+3+4+5+6
{
lc.setRow(0,0,B11111111);
lc.setRow(0,1,B11111111);
lc.setRow(0,2,B11111111);
lc.setRow(0,3,B11111111);
lc.setRow(0,4,B11111111);
lc.setRow(0,5,B11111111);
lc.setRow(0,BG_digit,BG_value6);
BG_value6 = (BG_value6 << 1)|1;
BG_counter++;
}
delay(50);
}