so den code habe ich auch dar wo ich ihn hin haben möchte:
Code:#define F_CPU 10000000UL #include <avr/io.h> #include <util/delay.h> int channel0; int channel1; void PowerOn(){ /**********Start Powerleds*******************/ DDRB |= 1<<PB0; /* set PB0 to output */ DDRB |= 1<<PB1; /* set PB1 to output */ PORTB |= (1 << PB0); /* LED0 on */ PORTB |= (1 << PB1); /* LED1 on */ /********************************************/ } void setPins(){ /**************Input*************************/ DDRB &= ~(1 << PB2); /* set PB2 to input*/ DDRB &= ~(1 << PB3); /* set PB3 to input*/ /********************************************/ /**************Ouput*************************/ DDRD |= 1<<PD6; /* set PB6 to output */ DDRD |= 1<<PD7; /* set PB7 to output */ PORTD &= ~(1<<PD6); /* PD6 off */ PORTD &= ~(1<<PD7); /* PD7 off */ /********************************************/ } void eventhandler(){ /**********Read Input PB2 and PB3*************/ if((PINB & (1 << PB2)) ) { channel0=1; channel1=0; } if((PINB & (1 << PB3)) ){ channel1=1; channel0=0; } if(channel0==1){ PORTD |= 1<<PD6; /* LED on */ PORTD &= ~(1<<PD7); /* LED off */ }else if(channel1==1){ PORTD |= 1<<PD7; /* LED on */ PORTD &= ~(1<<PD6); /* LED off */ } } int main(void) { setPins(); PowerOn(); channel0=1; while(1) { eventhandler(); } return 0; }







Zitieren

Lesezeichen