#ifndef F_CPU /* prevent compiler error by supplying a default */ #define F_CPU 1000000UL #endif #include #include #include volatile char pulselength = 200; //Volatile aufgrund von Interrupt.. char S1 = 0; char S2 = 0; char Direction = 1; volatile uint16_t AdcValue = 0; ///////////////////////////////////////////////////////////////////////////////////////////// // ADC Conversion read out ///////////////////////////////////////////////////////////////////////////////////////////// ISR(ADC_vect) { AdcValue = ADCH; // Nur die MSB werden übernommen /// //Sicherheitsüberprüfung ADC if ( AdcValue < 1 ) AdcValue = 0; if ( AdcValue > 253 ) AdcValue = 253; pulselength = AdcValue; // ADC auslesen } ///////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////// // Timer 0 interrupt ADC Conversion ///////////////////////////////////////////////////////////////////////////////////////////// ISR(TIMER0_OVF_vect ) { ADCSRA |= (1< calculate next signal ///////////////////////////////////////////////////////////////////////////////////////////// ISR(TIMER2_OVF_vect ) { //Vorwärtsbetrieb if (Direction) { if ((S1==1) && (S2==1)) { S1 = 0; S2 = 1; } else if ((S1==1) && (S2==0)) { S1 = 1; S2 = 1; } else if ((S1==0) && (S2==0)) { S1 = 1; S2 = 0; } else if ((S1==0) && (S2==1)) { S1 = 0; S2 = 0; } } // Rückwärtsbetrieb else if (!Direction) { if ((S2==1) && (S1==1)) { S2 = 0; S1 = 1; } else if ((S2==1) && (S1==0)) { S2 = 1; S1 = 1; } else if ((S2==0) && (S1==0)) { S2 = 1; S1 = 0; } else if ((S2==0) && (S1==1)) { S2 = 0; S1 = 0; } } if (S1) { PORTD |= (1<