In this illustration we will going to wire the Light Cup module, actually the light cup is device the when you move the mercury tilt switch the light will become dimming light, it uses Pulse with modulation (PWM) dimming principle. The mercury switch will provide a digital singal that triggers the PWM Pulse with Modulation through the code program.
The ideas comes from this module is for example if you to attach this module into the tree branch ones the wind push the brand the mercury switch also and along with the switch move the LED with dimming effect or any desired output.
Compare to vibration sensor the mercury switch is more sensitive because the valve itself has a liquid moving element to trigger.
This module has two parts an LED and a mercury tilt switch. The pin 1 is connection to ground and the pin 2 is connected to 5v power, the pin 3 is a signal and the pin 4 is the board LED, if you wire the pin1 and 2 to power, pin3 the signal will alternate between 5v and 0v or HIGH and LOW as you tilt the module. If you connect a current limiting resistor to pin 2 the output will flashing the LED.
Required Components
- Arduino Board
- Light Cup Module Board
- Jumper 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 14CORE TEST CODE FOR LIGHT CUP MODULE 8888888888888888888888888888888888888888888888888888888888 */ int MyLed1 = 5; int MyLed2 = 6; int BtnPin1 = 7; int BtnPin2 = 4; int buttonState1 = 0; int buttonState2 = 0; int brightness = 0; void setup() { pinMode(MyLed1, OUTPUT); pinMode(MyLed2, OUTPUT); pinMode(BtnPin1, INPUT); pinMode(BtnPin2, INPUT); } void loop() { buttonState1 = digitalRead(BtnPin1); if (buttonState1 == HIGH && brightness != 255) { brightness ++; // brightness increment to 1++ } buttonState2 = digitalRead(BtnPin2); if (buttonState2 == HIGH && brightness != 0) { brightness --; // brightness dincrement to 1-- } analogWrite(MyLed1, brightness); analogWrite(MyLed2, 255 - brightness); // LED Brightness turn to 255 delay(25); } |