Hey guys!
Today we will be learning how to make a Tilt indicator using magic light cup modules (KY-027). I have also done an alarm device using the mercury tilt switch , and you may have an idea of how the mercury tilt switch works.
The magic light cup modules come in pairs and each consists of a mercury tilt switch, LED and 10kΩ resistor. I will be using an Arduino Uno for this project, but you are also allowed to use an Arduino Nano. In this project, when the breadboard is horizontal (0° tilt) only one LED will be lit, and when the breadboard tilts, the second LED lights up. Not only the second LED lights up, but it also creates an illusion which almost makes us believe that the light is 'pouring' from first cup to the second one.
Supplies
- Arduino Uno/ Nano
- Solderless Breadboard
- Magic Light cup modules (x2) - KY-027
- Type A/ B USB cable (for Arduino Uno) / Type A to mini B USB cable (for Arduino Nano)
- Male-to-Male Jumper Wires (x16) - 10cm
- 3 pin Female-to-Female Jumper wires - 70cm
Setup
Your hardware setup must look somewhat similar to the one shown in the images above.
Connections
We are using only a pair of magic light cup modules as our components here.
- Signal of magic light cup module 01 - D8
- Signal of magic light cup module 02 - D7
- LED of magic light cup module 01 - D5
- LED of magic light cup module 02 - D6
- (+) - 5V
- (-) - GND (Ground)
Coding
Please refer to the project which I mentioned in the first paragraph, to learn about coding for a mercury tilt switch. The LED pins of the two modules are connected to the PWM pins. A LOW signal is sent when the mercury blob touches the metal contacts at the bottom of the switch. When there is a tilt, the mercury blob rolls down the switch and reaches the contacts. A low signal is sent and according to my codes, the LED loses its brightness slowly. The mercury blob in the magic light cup module at the bottom of the breadboard moves away from the contacts and a HIGH signal is sent. The LED increases its brightness till its analog value reaches 255.
If you need help with the coding, please feel free to comment below or send an email to arduinoprojectsbyr@gmail.com, and I will guide you.
Final Look
If anyone has any questions, or suggestions, about this project, please feel free to comment below, or send an email to arduinoprojectsbyr@gmail.com.
Comments
Post a Comment