Hardware Reference
In-Depth Information
Quick Reference Table
Configuring GPIO pins
Reading and writing GPIO pins
import RPi.GPIO as GPIO # RaspberryPi
GPIO.output(5, True) # set on (3.3V)
import anyio.GPIO as GPIO # Arduino
GPIO.output(5, False) # set off (0V)
GPIO.setmode(GPIO.BCM)
if GPIO.input(6) == False:
GPIO.setup(5, GPIO.OUT) # output
print("pressed")
GPIO.setup(5, GPIO.IN) # input
Safely cleaning up after using the
GPIO
Using the 7-segment display module
try:
import anyio.seg7 as display
do_something() # put code here
LED_PINS = [10,22,25,8,7,9,11,15]
finally:
ON = False # common-Anode
GPIO.cleanup()
ON = True # common-Cathode
display.setup(GPIO, LED_PINS, ON)
Writing characters to the 7-segment
display
Other 7-segment display functions
display.write("3")
display.setdp(True) # point on
display.write("A")
display.setdp(False) # point off
display.write("up")
display.clear()
display.pattern([1,1,1,1,1,1,1,1])
Further Adventures in
Electronic Circuits
In this adventure you have linked the Minecraft world to the physical world and
expanded your horizons into the fascinating world of physical computing by sensing
and controlling things in the real world. You have used this new knowledge to flash
LEDs, write patterns on 7-segment displays, and sense when buttons have been
pressed. But most importantly, you have escaped the confines of the Minecraft sand-
box world. With this new found knowledge you can make your own amazing game
controllers and display devices!
here wasn't enough space in this topic to do too many games with electronic
circuits, but when I started to think of ideas of games, I couldn't stop coming up
with new ones! The Minecraft Lift in the bonus chapter was one of the games I
just had to let you play with, which is why it is available for download from the
companion Wiley website—do try it out. I had hours of fun whizzing up and
down the lofty heights and murky depths of the Minecraft world with the lift
 
Search WWH ::




Custom Search