#include //Eingebundene Bibliotheken #include #include #include #include volatile char test=0; volatile int top=380, schritt=10, tasta=0, tastb=0; //TWI SLAVE EINSTELLUNGEN #define TWI_SLAVE_ADRESSE 50 //eigene SLAVE ADRESSE 1...127 #define TWI_GENERAL_CALL_enable 1 //1=Generral Call enabled / 0=disabled void Timer1_Init(void) { TCCR1A = (1< wr 0x... und bei jeden neuen wr 0x... test=TWDR; TWSI_w(); break; case TW_SR_DATA_NACK: //test=0x06; TWSI_w(); break; case TW_SR_GCALL_DATA_ACK: //test=0x07; TWSI_w(); break; case TW_SR_GCALL_DATA_NACK: //test=0x08; TWSI_w(); break; case TW_SR_STOP:// //test=0x09; TWSI_w(); break; //SLAVE TRANSMITTER case TW_ST_SLA_ACK: //test=0x0a; TWSI_w(); break; case TW_ST_ARB_LOST_SLA_ACK: //test=0x0b; TWSI_w(); break; case TW_ST_DATA_ACK: //test=0x0c; TWSI_w(); break; case TW_ST_DATA_NACK: // test=0x0d; TWSI_w(); break; case TW_ST_LAST_DATA: // test=0x0e; TWSI_w(); break; case TW_NO_INFO: //test=0x0f; TWSI_w(); break; case TW_BUS_ERROR: TWI_ERROR(); TWSI_w(); break; } } int main(void) { DDRB = 0xFF; //Alle Pins auf Ausgang PORTB = 0xFF; DDRD = 0xFF; //Alle Pins auf Ausgang PORTD = 0xFF; DDRC = 0x00; //PORT C alles EINGÄNGE twi_init(); //TWI INITIALISIERUNG Timer1_Init(); OCR1A=150; OCR1B=150; sei(); //alle Interrupts freigeben while(1) { switch(test) { case 'v': tasta=200; OCR1A=tasta; break; case 'h': tasta=tastb+schritt; OCR1A=tasta; break; case 'r': tasta+=schritt; OCR1A=tasta; break; case 'l': tasta=tastb+schritt; OCR1A=tasta; tastb=tasta; break; } } return 0; }