I'm trying to write a C program that will read the binary input on PORTB of the AVR and display the corresponding Hex digit on a single 7-segment display.
A bank of 4 DIP switches is connected to digital pins 8-11 (PB0->PB3). I have 5v from the arduino connected to switches 5-8. Switches 1-4 are connected to gnd on the arduino.
Here is a picture of the circuit:
The 7-seg display is correctly connected as I've tested it, but I'm not sure whether I've made a mistake in terms of the DIP switch and power/gnd connections. Or, if my code is wrong.
Here is the code:
Can you please help to point me in the right direction, thanks.