Orangutan SWITCH code

boy, i’m having the hardest time trying to write a simple, simple program just to check whether any of the three switches on the Orangutan is pressed. for example, if i’m interested in checking the status of SW3, shouldn’t the following work?

#define Testbit(x,y) (x&(1<<y)) // Returns 0 if clear, Bit value if set.

void main(void){
	unsigned char button_state;
	while(1){
	DDRB &= ~(1<<PB3);	// set at input
	button_state = Testbit(PORTB,PB3);
	if(button_state){
		beep();
		}
	}
}

Hi,

Try reading PINB instead of PORTB.

- Sean