Presentation is loading. Please wait.

Presentation is loading. Please wait.

Raspberry Pi: External Inputs & Outputs

Similar presentations


Presentation on theme: "Raspberry Pi: External Inputs & Outputs"— Presentation transcript:

1 Raspberry Pi: External Inputs & Outputs
Objective: to be able to program the Raspberry Pi to make use of external inputs and outputs.

2 External Inputs & Outputs
You can do even more with the Raspberry Pi by connecting it external input and output devices. This simple Input/Output board will help you learn how to work with external components. It features 3 LEDs, 3 switches, a button and a speaker.

3 Activity 1 In pairs, look at the program below and write out what you think might happen when it runs on a Raspberry Pi: What would you expect the Raspberry Pi to do?

4 Activity 2 Download and open the starter program on your Pi. Connect the Input/Output board to the pins on your Pi using male-female breadboard jumpers as shown below:

5 Give an example of how selection is used in the starter program.
Activity 3 In pairs answer the following questions: Question Answer Give an example of how selection is used in the starter program. Does anything happen to the LEDs when the button is pressed? If so what happens?

6 Place a screenshot of your completed code here
Activity 4a The starter program could be considered a basic alarm system, with the Button representing a pressure pad under a mat. However, a single red LED won’t attract much attention, so let’s improve it by making it flash. Place a screenshot of your completed code here Adapt the program to make the red LED flash on and off while the button is pressed and stop when the button is released.

7 Place a screenshot of your completed code here
Activity 4b Connect pin 18 to LED 3 and adapt your program so that the green LED is on when the button is NOT being pressed. This will indicate that the alarm is on but hasn’t been activated. Place a screenshot of your completed code here

8 Place a screenshot of your completed code here
Activity 4c Connect pin 23 to the buzzer on the INPUT/OUPUT board. Change the program so that when the alarm is activated the buzzer goes off. Tip: this example code will turn the buzzer on: Place a screenshot of your completed code here

9 Place a screenshot of your completed code here
Activity 4d Connect pin 24 to Switch 1 on the Input/Output board. Adapt your program so that the alarm is only active when Switch 1 is closed. Tip: the example code below will activate the buzzer when the switch is closed: Place a screenshot of your completed code here

10 Challenge Develop a program to control the lights the driver sees at a pelican crossing, based on the following description: The lights stay green until the pedestrian presses the button. 15 seconds after the button is pressed the light changes to amber for 3 seconds before changing to red. After 10 seconds have passed the red light should be turned off and the amber light should flash for 3 seconds before turning green again. This whole process should be repeated continually.


Download ppt "Raspberry Pi: External Inputs & Outputs"

Similar presentations


Ads by Google