Amer C. answered 29d
Learn Android Development from an Experienced Software Engineer
a simple way to implement that in C, assuming PB3 corresponds to Port B, bit 3 and that reading a 1 means the switch is not pressed and 0 means pressed:
If you want an Assembly version (for 8-bit AVR, returning the result in R6):