Hi everyone,
I am having some trouble with the picaxe vsm simulation software. I am trying to use a single button on pin0 to turn on an output for a relay on outpin1. The code i have used has worked perfectly fine for a real 28x1 microcontroller before, but it wont work for the 40x1 microcontroller simulated by the picaxe vsm.
The button turns the relay output on, but wont turn off. If i use a second button, it will turn on with pin0 and off with pin1 problem free. If i use a AND flag1=1 to identify between two different status of the problem, it turns on but still wont turn off with one or two buttons.
This code with two buttons, and works.
This code is with the flag1 being used to detect the status of the program, and detects pin0 when first pressed, but then does not switch off when pin1 button is pressed.
Ive used this code before in another project for a real 28x1 and a 28x2 microcontroller and it worked problem free in many places, please could someone look over these examples. I assume i am making a mistake some where, but i can not see it and i am beginning to assume it could be the simulator.
Any help would truly be welcomed, thank you.
NOS9
I am having some trouble with the picaxe vsm simulation software. I am trying to use a single button on pin0 to turn on an output for a relay on outpin1. The code i have used has worked perfectly fine for a real 28x1 microcontroller before, but it wont work for the 40x1 microcontroller simulated by the picaxe vsm.
The button turns the relay output on, but wont turn off. If i use a second button, it will turn on with pin0 and off with pin1 problem free. If i use a AND flag1=1 to identify between two different status of the problem, it turns on but still wont turn off with one or two buttons.
This code with two buttons, and works.
Code:
do
if pin0=1 then
gosub button1
elseif pin1=1 then
gosub button2
endif
loop
button1:
let flag1=1
let outpin1=1
gosub timer30
return
button2:
let flag1=0
let outpin1=0
gosub timer30
return
timer30:
value = 300
do until value = 1
if value > 1 then
value = value - 1
elseif value = 0 then endif
loop
Return
This code is with the flag1 being used to detect the status of the program, and detects pin0 when first pressed, but then does not switch off when pin1 button is pressed.
Code:
do
if pin0=1 AND flag1=0 then
gosub button1
elseif pin1=1 AND flag1=1 then
gosub button2
endif
loop
button1:
let flag1=1
let outpin1=1
gosub timer30
return
button2:
let flag1=0
let outpin1=0
gosub timer30
return
timer30:
value = 300
do until value = 1
if value > 1 then
value = value - 1
elseif value = 0 then endif
loop
Return
Any help would truly be welcomed, thank you.
NOS9