White LED Module


LED (Light-Emitting Diode)
LED is a commonly used light emitting device that converts electrical energy into light energy. Usually, it is used as an indicator in circuits and instruments, or as part of texts or numeric display.
It generally includes gallium(Ga), arsenic(As), phosphorus(P), nitrogen(N) and so on.
|
LED components |
Emitting light colors |
|---|---|
|
gallium arsenide diode |
red |
|
gallium phosphide diode |
green |
|
silicon carbide diode |
yellow |
|
gallium nitride diode |
blue |

Operating voltage: DC 3.3 ~ 5 V
Operating current: 1.5 mA (Peak: 2.3mA)
Maximum power: 0.07 W
Control signal: digital signal
Dimensions: 24 x 48 x 18 mm (without housing)
Positioning holes: diameter of 4.8 mm
Interface: telephone socket


Modules with blue housing are digital ones, so we should connect to digital io pins of the mainboard (ports with blue).

In this experiment, we connect the white LED module to port 1. According to the board ports view, the digital io pin at port 1 is digital pin D5.
When we set the pin to high(1), the LED lights up in white; if we set to low(0), it will be off.



Click
to connect to COM port and then
.
Explanation

Code Blocks
|
Blocks |
Code block |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

Conceive
1. Initialization
Set pin mode.

Build blocks:
① Drag
and
to the editing area.
② Click the triangle to choose pin 5.

③ Modify the mode into output .
Three pin mode:
input
output
input-pullup

Q :Why output?
A :The code is written for the mainboard. For the board, pin D5 is outputting power levels (high or low) to the connected module.


2. Main Code
Loop: LED lights on for 1s and goes off for 1s, in a loop.

Build blocks:
① Drag
.This is a loop code, in which codes will run forever.
② Drag
into “forever”.
There are two power level to output:
high
low
Choose pin to 5 and output high.
③ Drag
into “forever”. This is a delay code.

Q :Why delay 1s?
A :If you output a high level to LED, it will be always on. Yet, we add a delay of 1s, so it lights up for only 1s. Delay time is the ON/OFF time of LED.

Pin outputs high for 1s:

④ Right-click the code and choose “Duplicate”.

As follows:

Set the output to low. Pin 5 outputs low for 1s.

LED will lights on for 1s and goes off for 1s, in a loop.

Test Result

After uploading code, the LED module will flash with an interval of 1s (on for 1s and off for 1s).

