Navigation

Raspberry Pi

Raspberry Pi

Boot settings:

# nano /boot/cmdline.txt

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait bcm2708.w1_gpio_pin=18

Proxy:

Raspberry Pi - input button in pythoon

Raspberry Pi (B)

import RPi.GPIO as GPIO
import time
import os

#adjust for where your switch is connected
buttonPin = 3
GPIO.setmode(GPIO.BCM)
GPIO.setup(buttonPin,GPIO.IN)

while True:
  #assuming the script to call is long enough we can ignore bouncing
  if (GPIO.input(buttonPin)<>1):
    #this is the script that will be called (as root)
    os.system("echo Hello world")
    time.sleep(1)
Subscribe to Raspberry Pi