- #include <mega32a.h>
- #define ddigit_A DDRA
- #define digit_A PORTA
- #define ddigit_B DDRB
- #define digit_B PORTB
- #define ddigit_C DDRC
- #define digit_C PORTC
- #define ddigit_D DDRD
- #define digit_D PORTD
- const unsigned char digit[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f} ;
- void main(void)
- {
- float a = 12.78;
- int b = a * 100 ;
- int output[4] ;
- ddigit_A = 0xff;
- ddigit_B = 0xff;
- ddigit_C = 0xff;
- ddigit_D = 0xff;
- output[0] = b / 1000;
- output[1] = (b % 1000) / 100 ;
- output[2] = (b % 100) / 10 ;
- output[3] = (b % 10) ;
- while (1){
- digit_A = digit[output[0]];
- digit_B = digit[output[1]];
- digit_C = digit[output[2]];
- digit_D = digit[output[3]];
- }
- }
Recent Pastes