PDA

View Full Version : How can i control pic input pins order?



tanero
- 17th August 2005, 18:12
For example ,

Loop :
IF PORTA=254 then go1
IF PORTA=253 then go2
Goto Loop

go1:
WHILE PORTA=254
Pause 500
High portb.0
Pause 500
Low portb.0
Wend
Goto Loop


go2:
WHILE PORTA=253
Pause 500
High portb.1
Pause 500
Low portb.1
Wend
Goto Loop

All PORTA inputs goes like that .

My problem is that ;

if 1 of "if" is active there is no problem ; it does what should.

if 2 of "if" is active at the same time ; it doesn't do something , just wait . if i release one of 2 input pins ; it works well.

Questions;

is there a way to record input status to use order job. Mean , if one "if" is active it will do its job ; if second if is active (input low) , it will record this request , it will do its job after release first if .

Note: I just give a part of my code as example ; to be able to understandable . (All A ports will be used.)

If someone has an idea or some part of code to be used before , i will be happy.

CocaColaKid
- 17th August 2005, 18:49
Do you want to store the number of buttons pressed while the program is still running? For example you press 1 and then press 2 and 3 while 1 is running.

NavMicroSystems
- 17th August 2005, 19:13
tanero,

your code works as designed.

IF RA.0 only is LOW it will read 254 (%11111110)
IF RA.1 only is LOW it will read 253 (%11111101)

IF both RA.0 and RA.1 are LOW it will read 252 (%11111100)

so none of the IF... conditions is TRUE, that's why it is just LOOPing

You may want to check the port bits individually:

If PortA.0=0 THEN...
If PortA.1=0 THEN...

etc.

tanero
- 18th August 2005, 11:42
Answer for CocaColaKid ;

yes i want to store the number of buttons while 1 is working. After release 1 , then stored record will be worked.

tanero
- 18th August 2005, 11:53
Answer for ralph;

your right for guess . after read your post i changed my code as you offer it worked what i expected nearly.

But some other things i want to do .

Example ;
As PORT Bit loop = one of "if" condition is true , its doing its job. while first if working if second condition is true , second wont work and wait for the first one to be released .

I want ; while the first "if" is true and working ; second "if" true cond happened , it will store request and will do after first if released.

Any idea ?

İ thought to use internal eeprom area to store these requests .

is it usefull to use a like query ?

CocaColaKid
- 18th August 2005, 12:46
I would say they easist way would be to monitor the buttons when your in the if routines and record the button states. Then once you return to the main loop process what ever value is stored in the variable. This will only work for sequencing one button though.