Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Arduino.h>
- byte lut[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
- byte disp[]={B111110,B111101};
- byte d=0;
- byte x=0;
- byte x1,x2,xx;
- void setup()
- {
- DDRB=0xFF;
- DDRD=0xFF;
- TCCR1A=0x00;
- TCCR1B=0x00;
- TCNT1=0xF2F7; /// Timer 1 preset value
- bitWrite(SREG,7,1); /// Enable global interrupt
- bitWrite(TIMSK1,0,1); /// Enable TIMER1_OVF interrupt
- TCCR1B=0x05; /// Timer 1 ON
- }
- ISR(TIMER1_OVF_vect)
- {
- TCCR1B=0x00; /// Timer 1 off
- TCNT1=0xF2F7;
- x=x+1;
- if(x==100)
- {
- x=0;
- }
- xx=x;
- x1=0;
- x2=0;
- while(xx != 0)
- {
- xx=xx-1;
- x1=x1+1;
- if(x1>9)
- {
- x2=x2+1;
- x1=0;
- }
- }
- bitSet(TIFR1,2); /// TOV1 Clear
- TCCR1B=0x05; /// Timer 1 Off
- }
- void loop()
- {
- digitalWrite(13,LOW);
- delay(1);
- PORTB=disp[d];
- if (d==0)
- {
- PORTD=lut[x2];
- }
- else if (d==1)
- {
- PORTD=lut[x1];
- }
- delay(1);
- d=d+1;
- if (d>1)
- {
- d=0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement