Reading a dip switch as binary code?


hello everyone! i'm working on single 7 segment display project have enter binary numbers in 4-bit gray code , output decimal equivalent using ssd.

the approach: i'm using dip switch represent 4 bit gray code , i've set function switch statements light number. example, if set first 4 switches 0-1-0-1 in gray code, ssd display number 6, etc. question is: there way can save states of these switches , read them in binary? want save them type of integer because that's parameter switch function. possible? i'm new arduino i'm not sure how it's meant work.

i attached code. advice awesome!

code: [select]


byte grey = (pinstate1) ||( pinstate2 <<1) || (pinstate3 <<2) || (pinstate4 <<3)


Arduino Forum > Using Arduino > Programming Questions > Reading a dip switch as binary code?


arduino

Comments