From 4998d3a2e5c7517eacb94a99f106d04da31fb8be Mon Sep 17 00:00:00 2001 From: Thomas Klaehn Date: Sun, 20 Mar 2016 13:06:07 +0000 Subject: [PATCH] gpio class added --- gpio.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 gpio.py diff --git a/gpio.py b/gpio.py new file mode 100644 index 0000000..7cdad5a --- /dev/null +++ b/gpio.py @@ -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))