Habe den ISP Adapter abgesteckt leider ohne erfolg. Habe den Code nochmal über arbeitet und bereinigt.
Code:
#define F_CPU 10000000UL
#include <avr/io.h>
#include <util/delay.h>
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)) ) {
PORTD |= 1<<PD6; /* LED on */
}else {
PORTD &= ~(1<<PD6); /* LED off */
}
if(!(PINB & (1 << PB3)) ){
PORTD |= 1<<PD7; /* LED on */
}else{
PORTD &= ~(1<<PD7); /* LED off */
}
}
int main(void) {
setPins();
PowerOn();
while(1) {
eventhandler();
}
return 0;
}
Lesezeichen