hemnath
Advanced Member level 3
- Joined
- Jun 24, 2012
- Messages
- 702
- Helped
- 61
- Reputation
- 120
- Reaction score
- 57
- Trophy points
- 1,308
- Location
- Chennai
- Activity points
- 6,589
I have 4 buttons connected to pic 18F2520. which are configured as inputs. I'm using CCS c compiler
below is the routine i'm using now,
The problem is, i have to type so many lines to check the input status and the program becomes very large. Is there any simple solution to read the input?
Please help. Thanks in advance
below is the routine i'm using now,
HTML:
if((input(PIN_A1) == 0) && (input(PIN_A2) == 0) && (input(PIN_A3) == 0) && (input(PIN_A4) == 0)) // 0000
{
variable = 0;
}
if((input(PIN_A1) == 0) && (input(PIN_A2) == 0) && (input(PIN_A3) == 0) && (input(PIN_A4) == 1)) // 0001
{
variable = 1;
}
like this ... goes upto
if((input(PIN_A1) == 1) && (input(PIN_A2) == 1) && (input(PIN_A3) == 1) && (input(PIN_A4) == 1)) // 1111
{
variable = 15;
}
The problem is, i have to type so many lines to check the input status and the program becomes very large. Is there any simple solution to read the input?
Please help. Thanks in advance