Danke für die Tipps,
Ich habe das Problem jetzt so gelöst:
Jetzt funktioniert alles, wie es soll.Code:#include <util/delay.h> #include <avr/io.h> #include <avr/interrupt.h> #include "lib.h" unsigned char x, count; ISR (TIMER0_COMP_vect) { if (count>x) PORTA &= ~1; else PORTA |= 1; if (count < 200) count++; else count=0; } void long_delay(uint16_t ms) { for(; ms>0; ms--) _delay_ms(1); } void demo(uint8_t a) // Demo: ein Durchgang besteht aus linker Anschlag bis rechter Anschlag { // Anzahl der Durchgänge kan festgelegt werden uint8_t q; uint8_t i=14; for(q=0; q<a; q++) { for(i=14; i<67; i++) { long_delay(1000); x=i; } for(i=67; i>14; i--) { long_delay(1000); x=i; } } } int main(void) { delta_init(); timer0_init(); usart_init(); DDRA |= 1; demo(5); // Demo 5-Mal Ausführen while(1) { if(usart_byte_avail()) // Dann auf Befehle über UART warten { // links:67 , mitte:39 , rechts:14 x = readInteger(); } } return(0); }







Zitieren
Lesezeichen