Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # coding=utf8
- import os.path
- def gpio_create(fnum):
- fpath = "/sys/class/gpio/gpio" + str(fnum)
- if not os.path.isfile(fpath):
- file_ = open("/sys/class/gpio/export", "w")
- file_.write(str(fnum))
- file_.close()
- def gpio_set_direction(fnum, direction):
- fpath = "/sys/class/gpio/gpio" + str(fnum)
- if os.path.isfile(fpath):
- dpath = fpath + "/direction"
- file_ = open(dpath, "w")
- file_.write(str(direction))
- file_.close()
- def gpio_set_state(fnum, value):
- fpath = "/sys/class/gpio/gpio" + str(fnum)
- if os.path.isfile(fpath):
- vpath = fpath + "/value"
- file_ = open(vpath, "w")
- file_.write(str(value))
- file_.close()
- gpio_create(232)
- gpio_set_direction(232, 'out')
- gpio_set_state(232, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement