【RPi】 GPIO

パッケージの確認
$ sudo apt-cache –names-only search gpio

 

【io.py】

#!/usr/bin/python

import RPi.GPIO as GPIO
import time

#GPIO.setmode(GPIO.BCM) # use GPIO pin number
GPIO.setmode(GPIO.BOARD) # use board pin number

GPIO.setup(40,GPIO.OUT)

try:
while True:
GPIO.output(40,True)
time.sleep(1)
GPIO.output(40,False)
time.sleep(1)

except KeyboardInterrupt:
print "detect key intr."

GPIO.cleanup()

 

実行

#sudo python io.py

Leave a Reply