Hardware Reference
In-Depth Information
FIGURE 8-12 he Marshmallow Game
Creating the Marshmallow Button
he next step is to write the code to create a marshmallow button.
1. Open an LXTerminal window and type the following lines:
cd Documents
nano marshmallow.py
his code opens a new text editor window for you to type your Python code into
without having to open a Python IDLE shell and a text editor, and will name the
ile marshmallow.py .
2. Next type the following code:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(2, GPIO.IN)
while True:
if GPIO.input(2) == False:
print(“marshmallow makes a good input”)
time.sleep(0.5)
Search WWH ::




Custom Search