Chip type : ATmega8L Program type : Application Clock frequency : 16,000000 MHz Memory model : Small External SRAM size : 0 Data Stack size : 256 *****************************************************/ #include #include unsigned char ServoValue; unsigned char i; unsigned long TickCount; #define ADC_VREF_TYPE 0x40 interrupt [TIM0_OVF] void timer0_ovf_isr(void) { #asm("cli"); TCNT0=0x83; TickCount++; // Inkrement pocitadla milisekund #asm("sei"); } interrupt [EXT_INT0] void ext_int0_isr(void) { #define SIGNAL PORTD.2 #asm("cli"); if (!SIGNAL) { TCCR1B=0x03; } else { TCCR1B=0x00; ServoValue = (TCNT1L - 125) * 2; TCNT1H=0x00; TCNT1L=0x00; } #asm("sei"); } #define BRZDA PORTC.0 #define LED PORTC.1 void main(void) { while (1) { LED=1; // Kontrola funkčonsti MDU i=ServoValue; if (ServoValue > 50) BRZDA = 1; //ovládanie BRZD else BRZDA = 0; } }