Introduction
In this chapter, we are going to study about the GPIO Pins of BreadPi and will see how to program the Pins in Scratch, Python and C.
Components Required
- Raspberry Pi
- BreadPi
- LED x1
- Buzzer x1
GPIO Pins
Almost all the GPIO pins of the Raspberry Pi are on BreadPi for I/O or serial communication. The GPIO part of BreadPi is important as it uses TXB0104 bidirectional voltage-level translator. Which means the GPIO pins 7, 11, 13, and 15 gives 5 volts at the output side while at input end 3v3 is read. This is helpful for protecting GPIO from high voltages. You can use these pins for 5volt input-output operations. You can use pin 12, 16, 18, and 22 for 3v3 I/O operations. All the pins on GPIO sections can be used for digital input-output functionalities.
S. No. |
GPIO Pins |
BCM |
WiringPi |
1. |
P12 (3.3 V) |
18 |
1 |
2. |
P16 (3.3 V) |
23 |
4 |
3. |
P18 (3.3 V) |
24 |
5 |
4. |
P22 (3.3 V) |
25 |
6 |
5. |
P7 (5 v) |
4 |
7 |
6. |
P11 (5 v) |
17 |
0 |
7. |
P13 (5 v) |
21 | 2 |
8. |
P15 (5 v) |
22 |
3 |
Scratch
Scratch program for accessing the GPIO pins is a simple program, it’s a lot like the other LED blinking code. The when the green flag clicked from the event block is required to enable the entire program. The Forever block from the control acts as an infinite loop, the code inside the block will run forever.
PYTHON
This is a python program to control a LED and a Buzzer via tactical switches. While defining the switches as input don’t forget to add pull ups in it. In the while True section write condition for switches. If the SW1(switch 1) is high the LED will glow for 2 seconds. Else if SW2 is high then BUZZER will beep for 2 seconds.