1. Chapter LED
This chapter is the Start Point in the journey to build and explore RPi electronic projects. We will start with simple “Blink” project.
1.1. Project 01.0_Blink, 01.1_Keyboard_LED and 01.2 Sprite_LED
In this project, we will use RPi to control blinking a common LED.
1.1.1. Component List
Raspberry Pi (Recommended: Raspberry Pi 5 / 4B / 3B+ / 3B) (Compatible: 3A+ / 2B / 1B+ / 1A+ / Zero W / Zero) |
||
Breadboard x1 |
||
GPIO Extension Board & Ribbon Cable |
Resistor 220Ω x1 |
|
Jumper Specific quantity depends on the circuit. |
LED x1 |
|
In the components list, 3B GPIO, Extension Shield Raspberry and Breadboard are necessary for each project. Later, they will be reference by text only (no images as in above).
1.1.2. GPIO
GPIO: General Purpose Input/Output. Here we will introduce the specific function of the pins on the Raspberry Pi and how you can utilize them in all sorts of ways in your projects. Most RPi Module pins can be used as either an input or output, depending on your program and its functions.
When programming GPIO pins there are 3 different ways to reference them: GPIO Numbering, Physical Numbering and WiringPi GPIO Numbering.
1.1.3. BCM GPIO Numbering
The Raspberry Pi CPU uses Broadcom (BCM) processing chips BCM2835, BCM2836 or BCM2837. GPIO pin numbers are assigned by the processing chip manufacturer and are how the computer recognizes each pin. The pin numbers themselves do not make sense or have meaning as they are only a form of identification. Since their numeric values and physical locations have no specific order, there is no way to remember them so you will need to have a printed reference or a reference board that fits over the pins.
Each pin’s functional assignment is defined in the image below:
See also
For more details about pin definition of GPIO, please refer to http://pinout.xyz/
1.1.3.1. PHYSICAL Numbering
Another way to refer to the pins is by simply counting across and down from pin 1 at the top left (nearest to the SD card). This is ‘Physical Numbering’, as shown below:
1.1.4. Circuit
First, disconnect your RPi from the GPIO Extension Shield. Then build the circuit according to the circuit and hardware diagrams. After the circuit is built and verified correct, connect the RPi to GPIO Extension Shield.
Caution
Avoid any possible short circuits (especially connecting 5V or GND, 3.3V and GND)!
Warning
A short circuit can cause high current in your circuit, create excessive component heat and cause permanent damage to your RPi!
Schematic diagram
Hardware connection
Tip
If you need any support, please contact us via: support@freenove.com
Attention
Do NOT rotate Raspberry Pi to change the way of this connection.
Please plug T extension fully into breadboard.
The connection of Raspberry Pi T extension board is as below. Don’t reverse the ribbon.
Note
If you have a fan, you can connect it to 5V GND of breadboard via jumper wires.
How to distinguish resistors?
There are only three kind of resistors in this kit.
The one with 1 red ring is 10KΩ
The one with 1 red ring is 220Ω
The one with 1 red ring is 1KΩ
Note
Future hardware connection diagrams will only show that part of breadboard and GPIO Extension Shield.
1.1.5. Component knowledge
1.1.5.1. LED
An LED is a type of diode. All diodes only work if current is flowing in the correct direction and have two Poles. An LED will only work (light up) if the longer pin (+) of LED is connected to the positive output from a power source and the shorter pin is connected to the negative (-) output, which is also referred to as Ground (GND). This type of component is known as “Polar” (think One-Way Street).
All common 2 lead diodes are the same in this respect. Diodes work only if the voltage of its positive electrode is higher than its negative electrode and there is a narrow range of operating voltage for most all common diodes of 1.9 and 3.4V. If you use much more than 3.3V the LED will be damaged and burnt out.
Note
LEDs cannot be directly connected to a power supply, which usually ends in a damaged component. A resistor with a specified resistance value must be connected in series to the LED you plan to use.
1.1.5.2. Resistor
Resistors use Ohms (Ω) as the unit of measurement of their resistance (R). 1MΩ=1000kΩ, 1kΩ=1000Ω. A resistor is a passive electrical component that limits or regulates the flow of current in an electronic circuit. On the left, we see a physical representation of a resistor, and the right is the symbol used to represent the presence of a resistor in a circuit diagram or schematic.
The bands of color on a resistor is a shorthand code used to identify its resistance value. For more details of resistor color codes, please refer to the card in the kit package. With a fixed voltage, there will be less current output with greater resistance added to the circuit. The relationship between Current, Voltage and Resistance can be expressed by this formula: I=V/R known as Ohm’s Law where I = Current, V = Voltage and R = Resistance. Knowing the values of any two of these allows you to solve the value of the third.
In the following diagram, the current through R1 is:
Warning
Never connect the two poles of a power supply with anything of low resistance value (i.e. a metal object or bare wire) this is a Short and results in high current that may damage the power supply and electronic components.
Note
Unlike LEDs and Diodes, Resistors have no poles and re non-polar (it does not matter which direction you insert them into a circuit, it will work the same)
1.1.5.3. Resistor
Here we have a small breadboard as an example of how the rows of holes (sockets) are electrically attached. The left picture shows the ways the pins have shared electrical connection and the right picture shows the actual internal metal, which connect these rows electrically.
1.1.5.4. GPIO Extension Board
GPIO board is a convenient way to connect the RPi I/O ports to the breadboard directly. The GPIO pin sequence on Extension Board is identical to the GPIO pin sequence of RPi.
1.1.6. Code
According to the circuit, when the GPIO17 of RPi output level is high, the LED turns ON. Conversely, when the GPIO17 RPi output level is low, the LED turns OFF. Therefore, we can let GPIO17 cycle output high and output low level to make the LED blink. We will use both C code and Python code to achieve the target.
1.1.6.1. Blink
Hint
If you have any concerns, please contact us via: support@freenove.com
Load the code.
Freenove_Kit/Scratch3/01.0_Blink
Click the green flag, then the led will keep blinking until you click stop.
Usuall we make program from
which you can click on right.
There four modules in scratch for Raspberry Pi.
Click constumes, we will see there are two ball constume. We can also defin me more costumes. We will define three constume in RGB section.
Click this we can choose to use other sprites or upload a sprite.
1.1.6.2. Keyboard_LED
The circuit is same as previous section.
Tip
If you need any support, please contact us via: support@freenove.com
Load the code to scratch3.
Freenove_Kit/Code/Scratch3/01.0_Keyboard_LED.sb3
Click the green flag. Then when you press space key on your keyboard, the LED will be turned on. Otherwise, the LED will be turned off.
1.1.6.3. Sprite_LED
The circuit is same as previous section.
Tip
If you need any support, please contact us via: support@freenove.com
Load the code to scratch3.
Freenove_Kit/Code/Scratch3/01.2_Sprite_LED.sb3
Click the green flag. Then click the ball. The LED will be turned on or turned off.
So every time we click the ball the LED status will be changed.
1.1.7. Freenove Car, Robot and other products for Raspberry Pi
We also have car and robot kits for Raspberry Pi. You can visit our website for details.
https://www.amazon.com/freenove
FNK0043–Freenove 4WD Smart Car Kit for Raspberry Pi
FNK0050–Freenove Robot Dog Kit for Raspberry Pi
FNK0052–Freenove_Big_Hexapod_Robot_Kit_for_Raspberry_Pi





