3.6 Diodes and LEDs
Learning Objectives:
After this lesson, students can
- use ArduinoBlocks.com to program a Wemos D1 board;
- understand the working principles of LED and RGB LED;
- make a mini-project using Wemos D1 board, LED and RGB LED.
1. INTRODUCTION OF DIODES
A. Diodes
- In a diode, there are two leads: anode (正極) and cathode (負極).
- LED (light emitting diode) (發光二極管) is an example of diode.
- A diode allows current to flow in only one direction, not both.
- A diode can be a conductor (導電體) or insulator (絕緣體), so it is a semiconductor (半導體). Silicon (矽) is an example of semiconductor. P-type silicon and N-type silicon form a PN junction to make a diode.
- As a conductor (In forward bias): anode lead <--> +ve / cathode lead <--> -ve
- As an insulator (In reverse bias): anode lead <--> -ve / cathode lead <--> +ve
- Potential difference across the depletion region in the PN junction is about 0.7V.
- A diode can act as an insulator up to a maximum reverse voltage (反向電壓). Exceeding this voltage limit, it will conduct.
- Diode can be used in a rectifier (整流器) to convert AC (交流電) to DC (直流電) .
- Diode can be tested by a multimeter. It can measure the minimum voltage to turn on the diode and the current start to flow.
Siimulation : Forward and reverse bias | JavaLab
- In a diode, there are two leads: anode (正極) and cathode (負極).
2. LED, RGB LED
A. Light-emitting Diode (LED)

B. RGB LED

3. CLASSWORK
CW3.5.1 Task: Traffic Light (10 marks)
ArduinoBlocks Project Code: gNLQYOZL
Traffic Lights Pattern (Google Sheet)
The pattern sequence of the traffic lights for vehicles:
- Red -> Red & Yellow -> Green -> Yellow -> Red
The pattern sequence of the traffic lights for pedestrians:
- Red -> Green -> Green (Flashing) -> Red
1. Hardware Connection
The whole circuit will be completed on a breadboard. A bread board is a rectangular board which is having lots of HOLES to place electronic components in it.
Each column of breadboard are linked while power lines are linked horizontally.
Be careful of the breaks, the holes between breaks are not linked together.

We will be using 3 LEDs ( Red, Yellow, Green) to simulate the traffic light for vehicles.
There are two leads on the LED, the longer lead is the anthode (+) (connected to higher voltage) while the shorter lead is the cathode (-) (connecrted to lower voltage). In this task, the longer lead of each LED will be connected to an output pin of an Arduino board by a DuPont wire, and the shorter lead of each LED will be connected in series of a resistor to ground (0V).

A resistor should be connected in series of the LED, to limit the current through the LED and to prevent that it burns.
Hardware connection (Vehicle Light)
LED Wemos D1 board Red (Long Lead) D1 Yellow (Long Lead) D2 Green (Long Lead) D3 (-) power bus (with black or blue line) GND (0 V) The LED negative lead (shorter) of each LED is connected to a 220 ohm resistor. Another end of each resistor is connected to (-) power bus.
Hardware connection (Pedestrian Light)

RGB LED Wemos D1 board Red pin D6 Green pin D7 Usually, we need to use 3 resistors for each R, G, or B pins. However, to save time, we use one 220 ohm resistor connecting across the common cathode and GND.
Please refer to the following tinkercad circuit.
https://www.tinkercad.com/things/8N5C5MsEE3I
2. Programming in Arduinoblocks (www.arduinoblocks.com)
To light up a LED , we need to use "Write Digital Pin".
- ON: output HIGH voltage (3.3V DC for Wemos D1)
- OFF: output LOW voltage (0V DC)
Reference: Traffic Lights Pattern (Google Sheet)
