Physical computing in this context means programming and interacting with the real world through electronics. In this mini tutorial we will look a prototyping a simple traffic lights project using the raspberry pi, it will also introduce us to the forty GPIO pins.
What you will need:
- Raspberry pi
- Resistors 3
- LED (Light Emitting Diodes) 3
- Bread Board
- Connecting Wires (Male to Female, male to male)
Instructions:
- Connect the resistor to the negative end (Shorter leg)of the LED and the longer leg of the LED to GPIO pins 4, 17, 27
- Connect the other end of the resistor to ground, a resistor is required to limit the amount of current being drawn by each LED, to avoid damage to the Pi
- Breadboard Continuity is explained and should be understood before making connections
- Open your favorite text editor and write the code to control the LEDS
from gpiozero import LED #importing LED class from time import sleep red = LED(4) amber = LED(17) green = LED(27) green.on() amber.off() red.off() while True: sleep(10) green.off() amber.on() sleep(1) amber.off() red.on() sleep(10) amber.on() sleep(1) green.on() amber.off() red.off()
Credits: Raspberry PI Magpi Magazine