毎回調べるのもなんなんで...
GND | GPIO26 | GPIO19 | GPIO13 | GPIO06 | GPIO05 | ID_SD | GND | GPIO11 | GPIO09 | GPIO10 | 3.3v | GPIO22 | GPIO27 | GPIO17 | GND | GPIO04 | GPIO03 | GPIO02 | 3.3v |
GPIO21 | GPIO20 | GPIO16 | GND | GPIO12 | GND | ID_SC | GPIO07 | GPIO08 | GPIO25 | GND | GPIO24 | GPIO23 | GND | GPIO18 | GPIO15 | GPIO14 | GND | 5V | 5V |
echo 21 > /sys/class/gpio/export |
echo out > /sys/class/gpio/gpio21/direction |
echo in > /sys/class/gpio/gpio21/direction |
echo 1 > /sys/class/gpio/gpio21/value |
cat /sys/class/gpio/gpio21/value |
echo 21 > /sys/class/gpio/unexport |
#!/usr/bin/env python import RPi.GPIO as GPIO import os, time prev = 0 GPIO.setmode(GPIO.BCM) GPIO.setup(21, GPIO.IN, pull_up_down = GPIO.PUD_UP) def shutdown(channel): global prev now = int(time.time()) if now - prev >= 4 and now - prev <= 7: os.system("sudo shutdown -h now") prev = now GPIO.add_event_detect(21, GPIO.FALLING,callback= shutdown, bouncetime = 1000) while 1: time.sleep(100) |