User manual

92
Fig. 11.3: PiDance with LEDs and buttons using two breadboards
The buttons are built opposite to the associated LEDs. The two middle longitudinal rows of the breadboard
on both sides of the joint serve as the circuit’s 0 V and +3.3 V line.
The programme
pidance01.py contains the game.
# -*- coding: utf-8 -*-
import time, random
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
rnumber = 10; color = []
for i in range(w):
color.append(random.randrange(4))
LED = [4,18,23,24]
for i in LED:
GPIO.setup(LED[i], GPIO.OUT, initial=False)
BUT = [4,17,21,22]
for i in TAST:
GPIO.setup(i, GPIO.IN)
def LEDOn(n, z):
GPIO.output(LED[n], True); time.sleep(z)
GPIO.output(LED[j], False)
def Press():
while True:
if(GPIO.input(TAST[0])):
return 0
if(GPIO.input(TAST[1])):
return 1