Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 7372800UL
- #include <avr/io.h>
- #include <util/delay.h>
- uint8_t values[10] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f};
- uint8_t data[4] = {0, 0, 0, 0};
- void brData(uint16_t broj){
- for(int i = 3; i >= 0; i--){
- data[i] = broj%10;
- broj = broj/10;
- }
- }
- void funkcija(){
- brData(ADC);
- for(int i = 0; i < 4; i++){
- PORTD = values[data[i]];
- PORTB = _BV(i+4);
- _delay_ms(1);
- }
- }
- int main(void){
- DDRB = 0xff;
- DDRD = 0xff;
- PORTD = 0xff;
- ADMUX = _BV(REFS0) | 0;
- ADCSRA = _BV(ADEN) | _BV(ADPS2) | _BV(ADPS0);
- while (1) {
- ADCSRA |= _BV(ADSC);
- while(!(ADCSRA & _BV(ADIF)));
- funkcija();
- }
- }
Add Comment
Please, Sign In to add comment