'Put a code into a another, python totally new, im learning in the process, Raspberry
So im trying to put this:
import time
import RPi.GPIO as GPIO
def lrelay():
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(27, GPIO.IN)
GPIO.setup(5, GPIO.OUT)
GPIO.output(5, True)
BS1=False
try:
def switch(ev=None):
global BS1
BS1 = not BS1
if BS1 == True:
GPIO.output(5, GPIO.HIGH)
else:
GPIO.output(5, GPIO.LOW)
def button():
GPIO.add_event_detect(27, GPIO.FALLING, callback = switch, bouncetime=300)
def wait():
while True:
time.sleep(1)
button()
wait()
finally:
GPIO.cleanup()
into this one:
from feed import feeding
from water import pumpwater
from lightsonoff import lrelay
from multiprocessing import Process
if __name__ = "__main__":
w = Process(target=pumpwater)
f = Process(target=feeding)
l = Process(target=lrelay)
w.start()
f.start()
l.start()
w.join()
f.join()
l.join()
but, every time I push the button it tells me that BS1 is not define, when I run lightsonoff alone, works, but when I put it in the main program it do not work, please help, I do not know what to do T_T
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
