Skip to content
pauls1024 edited this page Jan 1, 2015 · 5 revisions

ref http://makezine.com/projects/tutorial-raspberry-pi-gpio-pins-and-python/

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)

GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP)

while True:

	if(GPIO.input(23) ==1):

		print(“Button 1 pressed”)

	if(GPIO.input(24) == 0):

		print(“Button 2 pressed”)

GPIO.cleanup()

Pin numbering is a bit confusing so might be easier to tell pyton to use the Pi header numbering instead of the BCM chip numbering ... or print out the names on a bit of paper and stick it to the Pi header.. ref http://www.doctormonk.com/2013/02/raspberry-pi-and-breadboard-raspberry.html

general python tutorial for GCSE http://usingpython.com/ and another one http://learnpythonthehardway.org/book/

python gui programming kivy looks interesting ... but only python2 can be packaged and deployed to android. http://karanbalkar.com/tag/kivy/ http://kivy.org/#home

Clone this wiki locally