#include avrio.h #include utildelay.h unsigned long time_reset = 0; int onoff[]={1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,1,1,1,1}; int volUp[]={1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1}; int volDown[]={1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,1,0,1,1,1,1}; int laenge = 32; int Onoff = 2; int VolUp = 3; int VolDown = 4; void setup() { pinMode(1, OUTPUT); Traegerfrequenz pinMode(0, OUTPUT); LED pinMode(Onoff, INPUT); onoff pinMode(VolUp, INPUT); volUp pinMode(VolDown, INPUT); volDown erzeug an PIN 1 die Traegerfrequenz TCNT1 = 0; TCCR1 = 0; GTCCR = (1 PSR1); section 13.3.2 reset the prescaler TCCR1 = (1 CTC1); section 12.3.1 CTC mode TCCR1 = (1 COM1A0); togle pin PB1 table 12-4 TCCR1 = (1 CS10); prescaler 1 table 12-5 OCR1C = 104; OCR1A = 104; } void loop() { if (digitalRead(Onoff)== HIGH) { onoff_sig(); } if (digitalRead(VolUp)== HIGH) { volUp_sig(); } if (digitalRead(VolDown)== HIGH) { volDown_sig(); } } void onoff_sig(){ digitalWrite(0, HIGH); delayMicroseconds(4500); digitalWrite(0, LOW); delayMicroseconds(4500); for(int i=0; ilaenge;i++){ if (onoff[i] == 1) { signal_1(); } if (onoff[i] == 0) { signal_0(); } } } void volUp_sig(){ digitalWrite(0, HIGH); delayMicroseconds(4500); digitalWrite(0, LOW); delayMicroseconds(4500); for(int i=0; ilaenge;i++){ if (volUp[i] == 1) { signal_1(); } if (volUp[i] == 0) { signal_0(); } } } void volDown_sig(){ digitalWrite(0, HIGH); delayMicroseconds(4500); digitalWrite(0, LOW); delayMicroseconds(4500); for(int i=0; ilaenge;i++){ if (volDown[i] == 1) { signal_1(); } if (volDown[i] == 0) { signal_0(); } } } void signal_0(){ time_reset = micros(); while((micros()-time_reset) 560){ digitalWrite(0, HIGH); } time_reset = micros(); while((micros()-time_reset) 560){ digitalWrite(0, LOW); } } void signal_1(){ time_reset = micros(); while((micros()-time_reset) 560){ digitalWrite(0, HIGH); } time_reset = micros(); while((micros()-time_reset) 1690){ digitalWrite(0, LOW); } }