Project 4 Controlling LED by Button Module
Project 4 Controlling LED by Button Module
Description:
In this project, we will control LED to light on and off via button module. When
the button is pressed, the signal end outputs low level (0); when released, the
signal end of sensor keeps high level(1).
Equipment:
Connection:
key module:
GND -- GND
VCC -- 5V
OUT -- D4
LED:
GND -- GND
SIG -- D5
Test Code:
Next to design the program, we make LED on by button. Comparing with
previous experiments, we add a conditional judgement statement. We use if
statement. The written sentences of Arduino is based on C language,
therefore, the condition judgement statement of C is suitable for Arduino, like
while, swich, etc.
For this lesson, we take simple “if” statement as example to demonstrate:
If button is pressed, digital 4 is low level, then we make digital 5 output high
level , then LED will be on; conversely, if the button is released, digital 4 is
high level, we make digital 5 output low level, then LED will go off.
As for your reference:
Test Result:
This experiment is pretty simple, and widely applied to various of circuits and
electrical appliances. In our life, you could find this principle on any device,
such as the backlight is on when press any buttons, which is the typical
appliance.