프로그램&회로

라즈베리파이 전원버튼 추가.

엠칩 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 로 종료 후 저장 한다.


반응형

'프로그램&회로' 카테고리의 다른 글

Terminal V1.9b 2013  (1) 2019.09.06
QMC5883 지자기센서  (0) 2019.01.16
라즈베리파이 네트워크 설정  (0) 2018.12.14
리눅스 콘솔 단축키 및 명령어  (2) 2018.12.14
PICKIT3 Programmer to GO  (0) 2016.07.22