Can't get the break command to work - Raspberry Pi Forums
hi,
putting house controller sand separator. sand separator needs purged each day 30 seconds in order allow our have clean water. original controller failed , company bought wants $800 new one!
bought
irrigation valve $24
raspberry pi $32
rpi 2 channel relay $8
dupont cables $3
had trolled web needed project done , got work. glorious watch purge every morning @ 8 am. connected ubiquiti subscriber module rpi ssh , control valve remotely if needed well.
micro sd card failed , coding , cron jobs went away. , hitting wall on basic script don't know python nor have ever coded. asking bit of help.
gpio pin 4 trip relay 30 seconds , stop. ideally, nice have noitfy me email did said function well. right now, using while true function, stuck in loop , don't know how make function happen once. tried using break function, kept getting errors.
here code:
#import necessary libraries
import rpi.gpio gpio
import time
gpio.setmode(gpio.bcm)
gpio.setup(4, gpio.out)
#this function turns valve off 1 second , on 30 seconds.
def valve_onoff(pin):
while 1:
gpio.output(4, gpio.high)
print("gpio high (on), valve should off")
time.sleep(1) #waiting time in seconds
gpio.output(4, gpio.low)
print("gpio low (off), valve should on")
time.sleep(30)
valve_onoff(4)
gpio.cleanup()
putting house controller sand separator. sand separator needs purged each day 30 seconds in order allow our have clean water. original controller failed , company bought wants $800 new one!
bought
irrigation valve $24
raspberry pi $32
rpi 2 channel relay $8
dupont cables $3
had trolled web needed project done , got work. glorious watch purge every morning @ 8 am. connected ubiquiti subscriber module rpi ssh , control valve remotely if needed well.
micro sd card failed , coding , cron jobs went away. , hitting wall on basic script don't know python nor have ever coded. asking bit of help.
gpio pin 4 trip relay 30 seconds , stop. ideally, nice have noitfy me email did said function well. right now, using while true function, stuck in loop , don't know how make function happen once. tried using break function, kept getting errors.
here code:
#import necessary libraries
import rpi.gpio gpio
import time
gpio.setmode(gpio.bcm)
gpio.setup(4, gpio.out)
#this function turns valve off 1 second , on 30 seconds.
def valve_onoff(pin):
while 1:
gpio.output(4, gpio.high)
print("gpio high (on), valve should off")
time.sleep(1) #waiting time in seconds
gpio.output(4, gpio.low)
print("gpio low (off), valve should on")
time.sleep(30)
valve_onoff(4)
gpio.cleanup()
please put code "code" block. first press "code" button above editing window/box, paste program text between code , /code tags.samalamading wrote: here code:
code: select all
#import necessary libraries import rpi.gpio gpio import time gpio.setmode(gpio.bcm) gpio.setup(4, gpio.out) #this function turns valve off 1 second , on 30 seconds. def valve_onoff(pin): while 1: gpio.output(4, gpio.high) print("gpio high (on), valve should off") time.sleep(1) #waiting time in seconds gpio.output(4, gpio.low) print("gpio low (off), valve should on") time.sleep(30) valve_onoff(4) gpio.cleanup()[/quote]
raspberrypi
Comments
Post a Comment