romel_emperado
Advanced Member level 2
- Joined
- Jul 23, 2009
- Messages
- 606
- Helped
- 45
- Reputation
- 132
- Reaction score
- 65
- Trophy points
- 1,318
- Location
- philippines
- Activity points
- 6,061
Hi guys,
I Have question in this scenario I have 8 parallel inputs w/ 8 switches and it is being pulled up by 8 resistors, so the normal values of my input read by the PIC when no switches pressed is 255.(all 8bit input are high/1)
the switch used is a push button switch.. NORmally open
when I press one switch located at PORTA.RA0 the input value will now be 255 -1 = 254..
the switch is momentary when I dont push it it will go back and the input value again will be 255.
so now the problem is I want to hold that value until the next activity of the switch. (the value 254)
I want to store that value inside a variable without losing it even if the switch is not press anymore
I tried something like this but after sometime inside a while 1 loop the value 254 disappear..
this is my code:
I Have question in this scenario I have 8 parallel inputs w/ 8 switches and it is being pulled up by 8 resistors, so the normal values of my input read by the PIC when no switches pressed is 255.(all 8bit input are high/1)
the switch used is a push button switch.. NORmally open
when I press one switch located at PORTA.RA0 the input value will now be 255 -1 = 254..
the switch is momentary when I dont push it it will go back and the input value again will be 255.
so now the problem is I want to hold that value until the next activity of the switch. (the value 254)
I want to store that value inside a variable without losing it even if the switch is not press anymore
I tried something like this but after sometime inside a while 1 loop the value 254 disappear..
this is my code:
PHP:
if(input != 255) //when any of the switch is pressed
store = input
return store;
Last edited: