Place to put your Basic demos and examples

Moderator: Mmiscool

User avatar
By forlotto
#33893
Code: Select allButton "On" [on]
Button "Off" [off]
Wait

[on]
Po 2 1
Wait

[off]
Po 2 0
Wait
User avatar
By kumaran512
#45575 NIce

I want to save the state of pin high or low after power off and on?
If the led is set at on with the button after power off of module and then power on, the led should still be on instead taking to its default value

I have gone through BASIC help and found

LASTSTAT:

This will return the last polled status of a pin such as an interrupt and retain the value until it has changed again in another polling event. Also it will allow you to see the last value sent to a pin for servo, pwm or po.
io(laststat,{pin no})

Just give me an example how to use it

Thanks in advance
User avatar
By forlotto
#45593 No what you do is define that as bla.

Compare it to 0.

If the status is zero then wprint "ON"
example: if bla = 0 then wprint " The Device is ON" else wprint "The Device is OFF"

Or if you don't care if it is 1 or 0 you could just say print bla after you tell the program what bla is (The LASTSTAT example you gave)

I did status with my own registers just have to be sure that you set them to 1 at the begining of your program as after a reset they will be turned off anyhow if you need more help I can just test something out for you and write something up this is all from basic memory I would have to actually run it through and program the latest version to know everything exactly works as stated as of right now I have a couple hour drive ahead of me so got to get out the door!

Take Care Hope this helps all.