엠칩
2018. 12. 17. 12:51
https://goo.gl/fEKsRW
1. 스위치 부착,... GPIO 17하고 GND
아래그림에서 9번 11번 사이에 스위치 부착

아래 소스에서 btnPin =5로 되어 있는데 나는 17번 사용할 것이니 17로 변경.
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN,pull_up_down=GPIO.PUD_UP) 외부에 풀업저항 안달고 내부 풀업 사용하는걸로....

3. /etc/rc.local 파일을 수정한다.
sudo nano /etc/rc.local
4. “exit 0″ 이전 라인에 아래 라인을 추가 한다.
python /home/pi/bin/button/shutdown.py
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/sbin/start-stop-daemon -b -c www-data:www-data -S -x /usr/bin/php /var/www/ttrss/update_daemon2.php -- -quiet
exit 0 |
#!/bin/sh -e #
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/sbin/start-stop-daemon -b -c www-data:www-data -S -x /usr/bin/php /var/www/ttrss/update_daemon2.php -- -quiet
python /home/pi/bin/button/shutdown.py
exit 0
|
Ctrl-X 로 종료 후 저장 한다.