In this post we include the Python code that triggers the motor to turn on when the rain sensor detects rain.
The motor will open the top of the tub so rain can be captured in the tub. The code also detects when the rain sensor is dry and will trigger the motor to spin the opposite way to close the top of the tub. This assures the water does not get polluted with outside elements when it is not raining. Download Rain Sensor Code
Note: this is the main script you want to call to run the rain sensor code. This script also imports motor_function.py which controls the motor so you will need to download both files for the rain sensor to work.
For those reading this who want to make their own Christmas Tree Circuit, following is where you can get the supplies
- Foam Christmas tree shapes from Michaels or Amazon has a bunch of foam Christmas tree shapes too if you do not have a Michaels near you.
- Battery Holders - you can get these in bulk from a supplier but you can also get them in smaller quantities from Amazon
- Copper Tape from Amazon. This will last you for a long time for many, many projects.
- Aluminum Tape from Amazon. This will last you for a long time for many, many projects.
- LEDs from Amazon. You can get smaller packs too but this is such a good deal especially if you anticipate using LEDs for other projects.
- 3v Cell Coin Batteries from Amazon
- Stickers, pipe cleaners -> dollar store & Michaels.