int mass[] = {
0b11111100,
0b01100000,
0b11011010,
0b11110010,
0b01100110,
0b10110110,
0b10111110,
0b11100000,
0b11111110,
0b11110110,
};
int massDigi[] = {
0b11111110,
0b11111101,
0b11111011,
0b11110111
};
int i=0;
uint16_t lastTime;
uint16_t Time,Time1,Time2;
int lastDigitTime;
int currentDigit;
int count;
void setup() {
//Serial.begin(115200);
DDRD = 0b11111111;
DDRB = 0b00001111;
DDRC = 0b100000;
//PORTB = 1 << 4;
}
bool flag=true;
void loop() {
if(!(PINC<<0)){
if(millis()-Time2>=150){
Time2=millis();
flag=!flag;
Serial.println(flag);
}
//BUTTON();
}
if(flag==true){
if(millis()-Time>=1000){
Time=millis();
count++;
if(count>=60){
count=60;
}
}
}
if(millis()-lastDigitTime>=5){
lastDigitTime=millis();
PORTD=0;
PORTB=massDigi[currentDigit];
PORTD=mass[zaloop()];
if(count%2){
zaloopaPolnayWithPoint();
}
currentDigit++;
if(currentDigit>=4){
currentDigit=0;
}
}
}
// void BUTTON(){
// if(millis()-Time1>=500){
// Time1=millis();
// while(flag){
// //Serial.println(flag);
// if(millis()-lastDigitTime>=5){
// lastDigitTime=millis();
// PORTD=0;
// PORTB=massDigi[currentDigit];
// PORTD=mass[zaloop()];
// if(count%2){
// zaloopaPolnayWithPoint();
// }
// currentDigit++;
// if(currentDigit>=4){
// currentDigit=0;
// }
// }
// if(!(PINC<<0)){flag=0;}
// }
// }
// }
int zaloop(){
int a;
if(currentDigit<2){
a=0;
}
if(currentDigit==2 ){
a=count / 10;
}
if(currentDigit==3){
a=count % 10;
}
//Serial.println(b);
return a;
}
void zaloopaPolnayWithPoint(){
PORTD|=0b00000001;
}
/*
if(i<10){
if(millis()-lastTime>=1000){
lastTime=millis();
PORTD=mass[i];
i++;
}
if(i>=10){
i=0;
}
}
*/
//sam sam
/*
if(i<10){
for(;i<10;i++){
del(1000);
PORTD=mass[i];
}
}else if (i>=10){i=0;}
}
*///sam sam