Check output state help

jtl

New Member
Hi

This is my first project and I want to be able to check the output state of say output 0 on a picaxe18x

I though some thing like

if 0 is high then high 1 endif
or
if high 0 then high 1 endif

But they both fail syntax check, is there away of doing this without setting a variable at the same time as setting the output to high or low?

Thanks
 

BCJKiwi

Senior Member
Check Manual 2 at the bottom of page 84 if .. then ... else etc.
When the if relates to a pin state rather than a variable value, the the syntax requires;
if pin0 is high etc.

you can also use 0 and 1 for low and high pin state
e.g.
if pin0 = 1 then high 1.

Note that the syntax also depends on whether the pin is on the left or right of the then.

It takes a while to get all the syntax requirements clear! perseverance and manual re-reads helps
 

inglewoodpete

Senior Member
....check the output state of say output 0 on a picaxe18x....
Reading the value that you have previously written to an output port or pin is not quite so straightforward. You may find it simpler to have a variable that mirrors the outputs (when setting an output pin, also set a bit in a variable to reflect the state of the pin). Generally, the PICAXE commands are structured so that you write to outputs and read from inputs.

I thinks it's possible to read the states of the output pins by doing a "Peek" into a specific location, but its not something I do so I'll leave that to you to look up the spcific PIC datasheet for the 18X (PIC16F88).
 
Last edited:

jtl

New Member
Thanks

wow thats what I call a forum, thanks for all the very quick responses, I am sure I will find this forum an invaluable in the future

Thanks
JTL
 
Top