Simulator Reset Problem

pilko

Senior Member
When I simulate an AND gate, (code attached).I still get an output after removing one or both inputs unless I use the reset button.I don't think I should need to use the reset button. If I don't,what am I doing wrong?
 

Attachments

SD2100

New Member
You need a LOW 1 command

Code:
main:
    if pin1 = 1 and pin2 = 1 then aa
    low 1 '<<<<---- turn it OFF
    goto main
aa:
    high 1
    goto main
 
Last edited:

hippy

Ex-Staff (retired)
You are setting the output with HIGH 1 but nowhere do you turn it off with a LOW 1. It will therefore stay on until reset or powered off.
 

pilko

Senior Member
Thanks guys,I apologise for the stupid question.I couldn't find this info anywhere in the manuals.
 

westaust55

Moderator
plus examples in Manual 2. Page 6 alone has this . . .


main: high 4
pause 1000
low 4
pause 1000
goto main
8. Click the PICAXE>Program menu to download the program to the hardware.
After the download the output LED should flash on and off very second.
 

pilko

Senior Member
westhaust and phil75 I really appreciate your help,but I am still confused.The examples you refer to in the manuals are to flash on and off.I am just trying to create a simple AND gate.
If I turn off an input and goto main why do I still get an output?
Please don't smack my bum for this question,I am getting too old!
 

Technical

Technical Support
Staff member
A 'high' comamnd switches an output on and leaves it on. After high has been processed the state of the inputs is no longer relevant - the output will stay on.

To switch the output off again you must use the 'low' to cancel out the 'high'.
 

westaust55

Moderator
how program flow works

westhaust and phil75 I really appreciate your help,but I am still confused.The examples you refer to in the manuals are to flash on and off.I am just trying to create a simple AND gate.
If I turn off an input and goto main why do I still get an output?
Please don't smack my bum for this question,I am getting too old!
To expand further on what Technical has said . . .

When you use the command "GOTO Main", this does not reset the PICAXE.
Variables retain the values they had and outputs retain their state, all as it was just before the "GOTO Main".

If you really want to reset everything, then you need to use the RESET command - see PICAXE manual 2 page 149.

So if you do not want to use the reset command becasue you want to retain the variable values etc, then you need to force the output to the next desired state. In your case off or LOW.

Hope that makes sense for you.
 
Top