#include #include #include #include uint16_t servo_currentcount; uint16_t rec_count_servo_1; uint16_t rec_servo_1; uint8_t w1; uint8_t w2; SIGNAL (SIG_OUTPUT_COMPARE0) { //Servo 1 Senden servo_currentcount += 1; if (servo_currentcount > 786) { servo_currentcount = 0; } //if (servo_currentcount < 59) if (servo_currentcount < rec_servo_1) { if (!(PORTC = 0b00000001)) { PORTC = 0b00000001; } } else { if (!(PORTC = 0b00000000)) { PORTC = 0b00000000; } } //Empfänger Kanal 1 auswerten if (PINA & 1) { rec_count_servo_1 +=1; } else { if ((rec_count_servo_1 > 0)) { rec_servo_1 = rec_count_servo_1; } rec_count_servo_1 = 0; } } int main(void) { //Status LED Einschalten DDRD = 0b10000000; PORTD = 0b10000000; for (w1=0;w1<255;w1+=1) { for (w2=0;w2<255;w2+=1); } //PORTC = Servoausgang DDRC = 0xFF; //PORTA = Empfängereingang DDRA = 0x00; //TIMER******************************** TCCR0 = 0b00000010; //Prescaler definieren (auf 1/8 clock) TCCR0 |= (1 << WGM01); //Output Compare einschalten (CTC-Modus) OCR0 = 10; TIMSK = (1 << OCIE0); //Output compare interrupt aktivieren sei(); //Global interrupts on //************************************* while(1) { //PORTC = PINA; if (rec_servo_1 == 59) { PORTD = 0b10000000; } else { PORTD = 0b00000000; } } }