#include "seven_leds_4digits.h"
#include <TimerOne.h>
seven_leds_4digits led;
long count = 0;
int val = 0, val2 = 0, data = 0;
int digit = 0;
const byte interruptPin = 2;
bool state_up=false;
void setup() {
// put your setup code here, to run once:
led.set_datapins(A0, A1, 4,5,6,7,8,9);
led.set_compins(13,12,11,10);
led.init();
Timer1.initialize(5000);
Timer1.attachInterrupt(display);
pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin),ADD,RISING);
Serial.begin(9600);
Serial.println("go");
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available())
data = Serial.parseInt();
if (val != data)
val = data;
}
void display()
{
led.showvalue(data);
led.flash();
if (state_up)
count++;
if (count>100000)
count=0;
data=count/100;
}
void ADD()
{
state_up=!state_up;
}
void blink()
{
}
/*
void display()
{
if (digit == 0)
{
led[3].turn_off();
val2 = val;
}
else
{
led[digit - 1].turn_off();
val2 /= 10;
}
led[digit].output(val2 % 10);
led[digit].turn_on();
digit++;
if (digit > 3)
digit = 0;
} */