const int ledPin = LED_BUILTIN;// the number of the LED pin
int ledState = LOW; // ledState used to set the LED
unsigned long previousMillis = 0; // will store last time LED was updated
const long interval = 250; // interval at which to blink (milliseconds)
// g f e d c b a
//zero 1 0 0 0 0 0 0 = 40h
//one = 1 1 1 1 0 0 1 = 79h
//two = 0 1 0 0 1 0 0 = 24h
//three 0 1 1 0 0 0 0 = 30h
int decimal[10] = {0x18, 0x0, 0x78, 0x2, 0x12, 0x19, 0x30, 0x24, 0x79, 0x40 };
int c = 0;
void setup() {
// put your setup code here, to run once:
for(int x=4;x<=10;x++) pinMode(x, OUTPUT);
for(int x=4;x<=10;x++) digitalWrite(x, 1); //off all
}
void loop() {
// put your main code here, to run repeatedly:
counting();
}
void counting() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
SSDone(decimal[c]);
c++;
if(c>=10) c=0; //back to 0
} else {
ledState = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
}
void SSDone(int theNum)
{
digitalWrite(4, theNum & 1);
digitalWrite(5, theNum & 2);
digitalWrite(6, theNum & 4);
digitalWrite(7, theNum & 8);
digitalWrite(8, theNum & 16);
digitalWrite(9, theNum & 32);
digitalWrite(10, theNum & 64);
}