Project 4 Button-controlled LED
1.Introductio
Button is a common control electrical apparatus element,used to turn-on or turn-off circuit, as a switch of controlling motor or operating other device.
In this project, we use graphical programming to control LED turning on or off.
2.Materials Required
KEYESTUDIO UNO Control Board *1
V5 Sensor Shield*1
Piranha LED*1
Button Module*1
Female to Female Dupont Line*6
3.Connection Diagram


4.Sample Code
void setup()
{
pinMode( 4 , INPUT);
pinMode( 10 , OUTPUT);
}
void loop()
{
if (( digitalRead(4) && HIGH ))
{
digitalWrite( 10 , HIGH );
delay( 50 );
}
else
{
digitalWrite( 10 , LOW );
delay( 50 );
}
}
5.Result
After finishing downloading, we can control LED by button module.