I'm getting an error when I use gpio.setup(pin, GPIO.OUT)
I'm currently using Ubuntu Mate For Raspberry Pi 2 and using Python 2.7 with python-rpi.gpio 0.5.10.1
module.
It throws SegmentationFault
when I try to input GPIO.setup(pin, GPIO.OUT)
.
EDIT: this is my code that i've been working on
# Program Menampilkan seven segment
import RPi.GPIO as GPIO
import time
# Atur mode GPIO menjadi nomor pin
GPIO.setmode(GPIO.BOARD)
# Atur pin ke segment 7segment
sega = 29
segb = 31
segc = 32
segd = 33
sege = 35
segf = 36
segg = 37
#Atur GPIO
GPIO.setup(sega, GPIO.OUT)
GPIO.setup(segb, GPIO.OUT)
GPIO.setup(segc, GPIO.OUT)
GPIO.setup(segd, GPIO.OUT)
GPIO.setup(sege, GPIO.OUT)
GPIO.setup(segf, GPIO.OUT)
GPIO.setup(segg, GPIO.OUT)
#Definisikan angka 7 segment 0 sampai 9
def nol(): # segment a, b, f, e, c, d hidup
GPIO.output(sega, GPIO.HIGH)
GPIO.output(segb, GPIO.HIGH)
GPIO.output(segf, GPIO.HIGH)
GPIO.output(sege, GPIO.HIGH)
GPIO.output(segc, GPIO.HIGH)
GPIO.output(segd, GPIO.HIGH)
time.sleep(1)
GPIO.output(sega, GPIO.LOW)
GPIO.output(segb, GPIO.LOW)
GPIO.output(segf, GPIO.LOW)
GPIO.output(sege, GPIO.LOW)
GPIO.output(segc, GPIO.LOW)
GPIO.output(segd, GPIO.LOW)
time.sleep(1)
return
def satu(): # segment b, c hidup
GPIO.output(segb, GPIO.HIGH)
GPIO.output(segc, GPIO.HIGH)
time.sleep(1)
GPIO.output(segb, GPIO.LOW)
GPIO.output(segc, GPIO.LOW)
time.sleep(1)
return
def dua(): # segment a, b, g, e, d hidup
GPIO.output(sega, GPIO.HIGH)
GPIO.output(segb, GPIO.HIGH)
GPIO.output(segg, GPIO.HIGH)
GPIO.output(sege, GPIO.HIGH)
GPIO.output(segd, GPIO.HIGH)
time.sleep(1)
GPIO.output(sega, GPIO.LOW)
GPIO.output(segb, GPIO.LOW)
GPIO.output(segg, GPIO.LOW)
GPIO.output(sege, GPIO.LOW)
GPIO.output(segd, GPIO.LOW)
time.sleep(1)
return
def tiga(): # segment a, b, g, c, d hidup
GPIO.output(sega, GPIO.HIGH)
GPIO.output(segb, GPIO.HIGH)
GPIO.output(segg, GPIO.HIGH)
GPIO.output(segc, GPIO.HIGH)
GPIO.output(segd, GPIO.HIGH)
time.sleep(1)
GPIO.output(sega, GPIO.LOW)
GPIO.output(segb, GPIO.LOW)
GPIO.output(segg, GPIO.LOW)
GPIO.output(segc, GPIO.LOW)
GPIO.output(segd, GPIO.LOW)
time.sleep(1)
return
def empat(): # segment f, b, g, c hidup
GPIO.output(segf, GPIO.HIGH)
GPIO.output(segb, GPIO.HIGH)
GPIO.output(segg, GPIO.HIGH)
GPIO.output(segc, GPIO.HIGH)
time.sleep(1)
GPIO.output(segf, GPIO.LOW)
GPIO.output(segb, GPIO.LOW)
GPIO.output(segg, GPIO.LOW)
GPIO.output(segc, GPIO.LOW)
time.sleep(1)
return
def lima(): # segment a, f, g, c, d hidup
GPIO.output(sega, GPIO.HIGH)
GPIO.output(segf, GPIO.HIGH)
GPIO.output(segg, GPIO.HIGH)
GPIO.output(segc, GPIO.HIGH)
GPIO.output(segd, GPIO.HIGH)
time.sleep(1)
GPIO.output(sega, GPIO.LOW)
GPIO.output(segf, GPIO.LOW)
GPIO.output(segg, GPIO.LOW)
GPIO.output(segc, GPIO.LOW)
GPIO.output(segd, GPIO.LOW)
time.sleep(1)
return
def enam(): # segment a, f, g, c, e, d hidup
GPIO.output(sega, GPIO.HIGH)
GPIO.output(segf, GPIO.HIGH)
GPIO.output(segg, GPIO.HIGH)
GPIO.output(segc, GPIO.HIGH)
GPIO.output(sege, GPIO.HIGH)
GPIO.output(segd, GPIO.HIGH)
time.sleep(1)
GPIO.output(sega, GPIO.LOW)
GPIO.output(segf, GPIO.LOW)
GPIO.output(segg, GPIO.LOW)
GPIO.output(segc, GPIO.LOW)
GPIO.output(sege, GPIO.LOW)
GPIO.output(segd, GPIO.LOW)
time.sleep(1)
return
def tujuh(): # segment a, b, c hidup
GPIO.output(sega, GPIO.HIGH)
GPIO.output(segb, GPIO.HIGH)
GPIO.output(segc, GPIO.HIGH)
time.sleep(1)
GPIO.output(sega, GPIO.LOW)
GPIO.output(segb, GPIO.LOW)
GPIO.output(segc, GPIO.LOW)
time.sleep(1)
return
def delapan(): # segment a, b, c, d, e, f, g hidup
GPIO.output(sega, GPIO.HIGH)
GPIO.output(segb, GPIO.HIGH)
GPIO.output(segc, GPIO.HIGH)
GPIO.output(segd, GPIO.HIGH)
GPIO.output(sege, GPIO.HIGH)
GPIO.output(segf, GPIO.HIGH)
GPIO.output(segg, GPIO.HIGH)
time.sleep(1)
GPIO.output(sega, GPIO.LOW)
GPIO.output(segb, GPIO.LOW)
GPIO.output(segc, GPIO.LOW)
GPIO.output(segd, GPIO.LOW)
GPIO.output(sege, GPIO.LOW)
GPIO.output(segf, GPIO.LOW)
GPIO.output(segg, GPIO.LOW)
time.sleep(1)
return
def sembilan(): # segment a, b, f, g, c, d hidup
GPIO.output(sega, GPIO.HIGH)
GPIO.output(segb, GPIO.HIGH)
GPIO.output(segf, GPIO.HIGH)
GPIO.output(segg, GPIO.HIGH)
GPIO.output(segc, GPIO.HIGH)
GPIO.output(segd, GPIO.HIGH)
time.sleep(1)
GPIO.output(sega, GPIO.LOW)
GPIO.output(segb, GPIO.LOW)
GPIO.output(segf, GPIO.LOW)
GPIO.output(segg, GPIO.LOW)
GPIO.output(segc, GPIO.LOW)
GPIO.output(segd, GPIO.LOW)
time.sleep(1)
return
for i in range (0, 5): # Tampilkan angka 1 sampai 9 x5
satu()
dua()
tiga()
empat()
lima()
enam()
tujuh()
delapan()
sembilan()
GPIO.cleanup()
I don't know the problem, i thought it was python-rpi.gpio module related as i don't have any problem with Raspbian with python-rpi.gpio pre installed.