In this Illustration we will going to wire the mercury switch module is a family of the tilt switching sensor, and it has an on-board LED as indicator as power status it can be used to build a simple circuit to produce tilt warning. The mercury tilt sensor interface has 3 pin the signal pin, ground pin and to voltage supply pin, if the signal pin detect a HIGH state the OUTPUT status will be HIGH.
Required Component
- Arduino Board
- Mercury Tilt Sensor
- LED Any Color
- Resistor
- Jumper / DuPont Wires
- Solder Less Bread Board
Wiring Diagram
Arduino Sketch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 14CORE TEST CODE MERCURY TILT SENSOR 8888888888888888888888888888888888888888888888888888888888 */ int MyLed = 13 ;// Define MyLed interface 13 as OUTPUT int MyMercury = 3; // define the mercury tilt switch sensor interface int MyVal ;// define numeric variables MyVal void setup () { pinMode (MyLed, OUTPUT) ;//Pin Mode define MyLed as output interface pinMode (MyMercury, INPUT) ;// Pin Mode define the mercury tilt switch sensor output interface } void loop () { MyVal = digitalRead (MyMercury) ;// To read the MyValues assigned to the digital interface 3 MyVal if (MyVal == HIGH) // When the mercury tilt switch sensor detects a signal, MyLed Turn HIGH { digitalWrite (MyLed, HIGH); //Turn LED to HIGH/ON } else { digitalWrite (MyLed, LOW); //Turn LED to LOW/OFF } } |
Wiring the Mercury Type Tilt Sensor
im a noob so probably wrong but the wiring diagram has 2 pin 13’s is that correct ?
int MyLed = 13 ;// Define MyLed interface 13 as OUTPUT
int MyMercury = 3; // define the mercury tilt switch sensor interface
Actually the diagram is wrong, Mercury should connected to pin digital pin3 on your Arduino and the output will be in the pin13.
—————————————————————————————————
See the code below the coe you can used this code as you can see instead using a
relay change it to LED as the output.
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14CORE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
TEST CODE FOR SOUND DETECTION SWITCH
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
int MyRelay = 8; //Relay Module to drive the output device
int MySensor = 9; // Sound Detection Sensor at pin 9
boolean SensorState = false; // Detect the if its true or false
void setup()
{
pinMode(MyRelay, OUTPUT); // Relay mode as output
pinMode(MySensor, INPUT); // Sensor mode as input
}
void loop()
{
if (digitalRead(MySensor) == LOW) //If Sound sensor detect a sound
//ll enabled the relay output
{
delay(100); //Delay as 1 micro second
SensorState = !SensorState;
digitalWrite(MyRelay, SensorState); //If Sound sensor detect a
//und will enabled the relay output
}
}
How much OHMs do we use for a resistor
For LED side you can place 220k Ohms.
Pingback:Wiring the 14CORE 37 Sensors for Arduino & Raspberry Pi | 14Core.com