-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
How can we set the GPIO to OFF State on page load.
https://sourceforge.net/p/raspberry-gpio-python/wiki/Home/
https://docs.python.org/2/library/sys.html
https://docs.python.org/2/library/json.html
#getting the main GPIO libraly
import RPi.GPIO as GPIO
#time and json
import time
import json
setting GPIO mode
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(22, GPIO.OUT)
GPIO.setup(23, GPIO.OUT)
GPIO.setup(24, GPIO.OUT)
GPIO.setup(25, GPIO.OUT)
GPIO.output(22, 1)
GPIO.output(23, 1)
GPIO.output(24, 1)
GPIO.output(25, 1)
setting a list of used pins
pins = [22, 23, 24, 25]
create empty list
arr = []
for loop from 0 to 3
for x in range(0,4) :
#putting all relays in on state if GPIO is not setup
#putting the relay state in the empty list
arr.append(not GPIO.input(pins[x]))
printing the list of state's in json format
print json.dumps({0:arr[0],1:arr[1],2:arr[2],3:arr[3]})
Already tried above but once you refresh the page it sets them to off again.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels