int mass[] = {
0b11111100,
0b01100000,
0b11011010,
0b11110010,
0b01100110,
0b10110110,
0b10111110,
0b11100000,
0b11111110,
0b11110110,
};
int massDigit[] = {
0b11111110,
0b11111101,
0b11111011,
0b11110111
};
int i=0;
uint16_t lastTime;
uint16_t Time,Time1,Time2;
uint16_t time4,time5,time6,time7;
int lastDigitTime;
int currentDigit;
int count;
int cc;
int raz1,raz2,raz3,raz4;
int h;
int d;
bool flag=true;
void setup() {
DDRD = 0b11111111;
DDRB = 0b00001111;
DDRC = 0b100000;
}
void loop() {
// while(millis()<5000){
// fio(0015);
// if(millis()-time5>10){
// time5=millis();
// while(h<4){
// switch(h){
// case 0:
// PORTD=0b00000000;
// PORTB=massDigit[h];
// PORTD=mass[0];
// break;
// case 1:
// PORTD=0b00000000;
// PORTB=massDigit[h];
// PORTD=mass[0];
// break;
// case 2:
// PORTD=0b00000000;
// PORTB=massDigit[h];
// PORTD=mass[raz3];
// break;
// case 3:
// PORTD=0b00000000;
// PORTB=massDigit[h];
// PORTD=mass[raz4];
// break;
// }
// h++;
// if(h>=4){h=0;}
// }
// }
// }
if(!(PINC<<0)){
if(millis()-time7>=150){
time7=millis();
flag=!flag;
cc++;
if(cc==3){
cc=0;
}
}
}
if(flag==true){
if(millis()-Time>=1000){
Time=millis();
count++;
if(count>=33){
count=33;
}
}
}
if(millis()-lastDigitTime>=10){
lastDigitTime=millis();
PORTD=0;
PORTB=massDigit[currentDigit];
PORTD=mass[DD()];
if(cc==2){
PORTD=mass[null()];
}
if(count%2){
Point();
}
currentDigit++;
if(currentDigit>=4){
currentDigit=0;
}
}
}
void fio(int razbivka){
raz1=razbivka/1000;
raz2=razbivka%1000/100;
raz3=razbivka%100/10;
raz4=razbivka%10;
}
int null(){
int n;
if(currentDigit<2){
n=0;
}
if(currentDigit==2 ){
n=0;
}
if(currentDigit==3){
n=0;
}
return n;
}
int DD(){
int a;
if(currentDigit<2){
a=0;
}
if(currentDigit==2 ){
a=count / 10;
}
if(currentDigit==3){
a=count % 10;
}
return a;
}
void Point(){
PORTD|=0b00000001;
}