Project 15 Tilting Switch Module
1.Introduction
When one side of the switch tilts below horizontal position, the switch is on; When the other side of the switch tilts below horizontal position, the switch is off.
In the project, we use graphical programming to control the on and off of LED, tilting module used as a button.
2.Materials Required
KEYESTUDIO UNO Control Board *1
V5 Sensor Shield*1
Piranha LED*1
Tilting Switch Module*1
Female to Female Dupont Line*6
3.Connection Diagram


4.Sample Code
void setup()
{
pinMode( 3 , INPUT);
pinMode( 6 , OUTPUT);
}
void loop()
{
if (( digitalRead(3) && HIGH ))
{
digitalWrite( 6 , HIGH );
delay( 100 );
}
else
{
digitalWrite( 6 , LOW );
delay( 100 );
}
}
5.Result
After the program is downloaded, we can use tilting switch module to control LED.