/* Fernbedienung für Dunstabzugshaube Emulation der originalen Fernbedienung von Siemens 12026292 */ #define F_CPU 9600000 // Hz #include "avr/io.h" #include "avr/interrupt.h" #include "avr/sleep.h" #include "avr/pgmspace.h" #include "util/delay.h" #define F_CARRIER 38000 // Hz #define CARRIER_PERIOD (F_CPU/(2*F_CARRIER)) // Trägerfrequenz für IR #define PULSE_WIDTH (CARRIER_PERIOD/3) // Tastverhältnis ca. 33% #if CARRIER_PERIOD > 255 #error F_CPU zu hoch, Prescaler benutzen #endif #define LED_ON PORTB |= (1<0; cnt--) { send_cmd(cmd); for(j=0; j<4; j++) { set_sleep_mode(SLEEP_MODE_IDLE); sleep_mode(); } } } void sequence_Power_Automatic(void) { send_cmd_multi(cmd_Power, 3); send_cmd_multi(cmd_Automatic,3); } void sequence_Light(void) { send_cmd_multi(cmd_Light, 3); } uint8_t get_key_press( uint8_t key_mask ) { cli(); // read and clear atomic ! key_mask &= key_press; // read key(s) key_press ^= key_mask; // clear key(s) sei(); return key_mask; } int main(void) { // IOs initialisieren DDRB = (1<1: key press detect } }