I tested this sample and it works. I now will make the video showing the relay running the water heater in action.
And many thanks to Richard Russell for helping me understand how to do this.
Code: Select all
REM Initialise GPIO:
INSTALL @lib$ + "gpiolib"
GPIO% = FN_gpio_setup
REM custom command for 1 pin use (I will make a mass pin tool later)
PROC_pinprep(24):REM assumes that you are just using 1 pin(GPIO 24
PROC_pin(24,"ON"):REM turn on pin 24 for relay
WAIT 20:REM lets assume that my water takes this long to heat
PROC_pin(24,"OFF"):REM turn off pin 24
END
REM lets make it custom
REM so for example PROCpin(24,"ON") or PROCpin(24,"OFF")
DEF PROC_pin(pin%,onoff$)
IF onoff$="ON" THEN PROC_gpio_set(GPIO%, 1 << pin%)
IF onoff$="OFF" THEN PROC_gpio_clr(GPIO%, 1 << pin%)
ENDPROC
REM made this to do the required pin input/output cycle
DEFPROC_pinprep(pin%)
PROC_gpio_inp(GPIO%, pin%)
PROC_gpio_out(GPIO%, pin%)
ENDPROC