product description:
Made of high-quality materials, these modules are crafted with high strength and durability for long-term use. They are also stable and reliable in terms of professional design performance. Suitable for development and application, these digital temperature sensor modules are ideal for DIY projects.
Mercury switch module and digital 13 interface with LED to build a simple circuit to produce tilting lights
As the digital 13 interface comes with an LED, the mercury tilt switch sensor is connected to the digital 3 interface. When the mercury tilt switch sensor has a button signal, the LED light is on, and vice versa.
Regular source code:
Int Led = 13; //Define the LED interface
Int buttonpin = 3; //Define the mercury tilt switch sensor interface
Int val; / / define the numeric variable val
Void setup()
{
pinMode (Led, OUTPUT); / / define the LED as an output interface
pinMode(buttonpin, INPUT); // Define the mercury tilt switch sensor as the output interface
}
Void loop()
{
Val = digitalRead(buttonpin); //Write the value of digital interface 3 to val
If(val == HIGH)//The LED flashes when the mercury tilt switch sensor detects a signal
{
digitalWrite(Led,HIGH);
}
other
{
digitalWrite(Led,LOW);
}
}
Shipping list:
Mercury Switch Module KY-017 Mercury Sensor Module *1pcs
There are no reviews yet.