How do I determine the staus of an output?

What I would like to know is if I can determine the status of the output pins. FOr example if output pin 4 is on then I would like to turn on another output but how do I create an if statement for this If outpin4 =1 then ..... does not work and if I use If pin4 =1 then... the program thinks I am refering to the condition of input pin 4
 

moxhamj

New Member
If something else made pin4=1 then you would be using pin4 as an input so "if pin4 = 1" would be the code to use.

However, the problem I think you are referring to is when you have made pin4 high somewhere in a program and then later you want to check its status. You need a way of tracking the status of pin4 and the easiest way is whenever you change pin4 then you set a flag somewhere. Eg every time you use high 4 you also add b0=1 underneath, and every time you say low 4 you add b0=0 underneath. Now you can check the status of pin4 in other parts of the program by checking the value of b0.

There are also hardware solutions using a capacitor to temporarily store the status of output pin 4 while it is briefly turned into an input. However I think this ends up using more code.

I think this answers your question but if not please add a few more details.
 
Output pin status

Yes that is exactly what I am trying to do, to determine the if an output is on or not. I am using the idea of a flag B1, but it is not the exact same as if the output pin is on or not, good enough I suppose but I thought there would be a more elegant way of doing it.

I also am stuck trying to use the input pin ADC 2/Ina2 on the 28x but it does not allow me to specify it as "pina2" how do I address this as a simple input?

I am using Version 5.0.7 of the softare thanks for your help
 

hippy

Technical Support
Staff member
If outpin4 =1 then ..... does not work
It should.

Are you using the Simulator or a real PICAXE, and if a real PICAXE, which variant / Firmware version ?

And what exactly do you mean by "does not work" ? Does it compile or give an "Error in this line" syntax error.

Try upgrading to the latest 5.1.5 Programming Editor.
 
Top