This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)"
* are you tired of spelling drink on the table ? this is an issue that everyone faces. with the help of an ultrasonic sensor and an Arduino .. I have found a cool , cheap to construct, solution ..
with only an easy code. you can solve this problem completely.
Step 1: Parts
2- ultrasonic sensor
4- 5v air pump
8- IR receiver
9- Arduino nano
Step 2: Build the Circuit
attached , is the circuit diagram .
Here are the pins for all the parts :
servo Motor 10
* you can change these pins . However, make sure the code matches your connections.
Step 3: Code
there are two codes.. the first one is getting the address for the buttons you want to use to open and close the lid. I used + to open , - to close. run the code and open the serial monitor. press the button for opening and copy the value you get in the serial monitor ( PRESS LGHTLY). paste the number you got instead of (0xFF18E7) . repeat with the closing button. then, close the serial monitor and the remote code. and upload the project code to the Arduino.
* please view the uploaded video to see the results after uploading the code.
don't forget to download the needed libraries.
* for the project code ..
there are three codes need to be added together . first cope the project code and add it to Arduino , then creat two new taps , one for .cpp and one for .h.
Step 4: Mechanical Design.
attached is the 3D animated video of the machine's design . also, STL files are uploaded if you want to 3d print it.. you can also build the machine with hand by using a foam, or cardboard. I used a foam in my design because it has a lighter weight.
*Dimensions depends on the size of soda bottle you want to use.
Step 5: How It Works ?
After connecting the system with power firstly void setup content will run .one of most important event is initializing IR remote reciver which depend mainly on timer prepheral in its operation. then attach servo signal line also to selected pin. after that void loop function will run. the distance is measured . if it less than 5 cm relay signal will goes high to power on pumb and if distance is more than 5 cm relay signal will go low to disconnect power of pumb. then check if any remote button is pressed or not, so if button is pressed get the reading or IR then compare it to know which button is pressed, so if open button is pressed, servo will rotate to open angle. else if off button is pressed servo will rotate to close angle. after that the cycle of void loop will be repeated again.
Step 6: Servo Motor
there is an adjustment need for the servo motor o achieve this project. the servo motor's role in this project is to open and close the machine's lid using a remote controller. a longer thing need to be glued to the servo motor. it can be a wooden stick, or a foam piece as I used in this project, then the whole servo motor will be glued to the side of the machine. please refer to the images attached.
Step 7: Power
this project can be powered with 5 to 12 V battery. you can power it with the Arduino cable connected to a power outlet as I did. or , you can attach a 9V battery adapter to a 9 V battery. and trim to ends to connect it to the breadboard. REMEMBER, connect to positive side of the 9v battery to the Vin pin in the Arduino , not the 5v pin because the 5v pin can only hold 5v not 9.