gpio class added
This commit is contained in:
commit
4998d3a2e5
22
gpio.py
Normal file
22
gpio.py
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
class gpio:
|
||||
def __init__(self, pin):
|
||||
self.pin = pin
|
||||
|
||||
def export(self):
|
||||
f = open("/sys/class/gpio/export", "w")
|
||||
f.write(str(self.pin))
|
||||
|
||||
def unexport(self):
|
||||
f = open("/sys/class/gpio/unexport", "w")
|
||||
f.write(str(self.pin))
|
||||
|
||||
def direction(self, direction = "out"):
|
||||
f = open("/sys/class/gpio/gpio" + str(self.pin) + \
|
||||
"/direction", "w")
|
||||
f.write(direction)
|
||||
|
||||
def set(self, value = 0):
|
||||
f = open("/sys/class/gpio/gpio" + str(self.pin) + \
|
||||
"/value", "w")
|
||||
f.write(str(value))
|
Loading…
Reference in New Issue
Block a user