Isn't this annoying and traumatic?
Not to worry anymore as using this guide and a few objects lying around your garage, you can ensure that your pet never goes hungry again and you can feed him/her remotely at the click of a button.
The main aim is to remotely feed your pet at the click of a button. On receiving the command from you, the housing should then open and close a trap door which would automatically dispense treats to the hungry waiting pet.
Step 1: Avengers, Assemble!- Cardboard pieces. (Preferably large up or up to your liking)
- Pair of scissors.
- Sturdy plastic spoon.
- 1 inch nail.
- Hot Gun Glue.
- Marker.
Connect the Bolt device to the Boltduino. Power up the Boltduino and make sure that the Bolt device is connected to a working WiFi network and the green LED is glowing.
Step 2: Fabricate the HousingIn order to make the housing of your pet feeder, select a few pieces of cardboard that are sturdy enough. You can also choose different materials for your housing if you like.
Next, form two 'L' shapes with the cardboard pieces which are identical. Mark 5cms from the bottom of the short hand of the 'L'. Refer the image below for any clarification. Label the two 'L's as A1 and A2 respectively.
Next cut a rectangular piece of cardboard that is about 7 cm longer than the width of your housing and about 3 cm smaller than the thickness of your housing. Label this part as 'B'.
Make a hole in the spoon which is slightly larger than the nail that you are using as a pivot and insert the nail through it. Make sure that the spoon can rotate freely about the nail like a fidget spinner.
Next heat up the gun glue and glue the nail to the part labeled B. Make a rectangular hole 2cm by 2cm in part B which is roughly 3cm left of the centre.
In part A1, about 8 cm from the bottom, glue a rectangular piece of cardboard which is equal to the length and breadth of A1.
Cut a rectangular hole in cardboard above which is roughly in the center.
In parts A1 and A2, cut a rectangular hole which is roughly 1 cm in height and slightly lesser than the width of parts A1 and A2.
Now glue A1 and A2 together so that they form a rectangular box and the cuts that you have made in the step above line up.
Insert part B through the slits in the now joined parts A1 and A2 and check if it moves freely through the slits.
Attach the spoon to the servo motor and your now completed housing should look like the completed product without the Bolduino attached to it.
The completed housing would be enough to store treats for feeding a cat a couple of times in my design. You can increase the storage if your pet's appetite is voracious.
Note - I will be creating and adding a step by step video showing how to make the housing.
Step 3: Connect the various componentsThe servo motor should have three wires coming out of it which may be Black(GND), Red(5V) and White(PWM input) in colour.
Connect the jumper cables from the Servo motor to the Boltduino in the fashion given below:
- Boltduino <-- --> Servo motor
- 5V <-- -- Red Wire
- GND <-- -- Black Wire
- Pin 9 -- --> White Wire
For further clarity, refer the Fritzing diagram.
Step 4: Write codesWrite code for Boltduino using the Arduino IDE and upload it to the Boltduino.
#include<Servo.h>
Servo servo;
const int LED_PIN = LED_BUILTIN; // The number of the LED pin
int SERVO_PIN = 9; // The pin which the servo is attached to
int CLOSE_ANGLE = 0; // The closing angle of the servo motor arm
int OPEN_ANGLE = 60; // The opening angle of the servo motor arm
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(LED_PIN,OUTPUT);
servo.attach(SERVO_PIN);
servo.write(CLOSE_ANGLE); // Close the trapdoor when it first boots up
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()){
char c = Serial.read(); // Read data sent by the cloud
switch(c){
case 'a' : digitalWrite(LED_PIN,HIGH); // If character received is 'a', dispense the treat
open_door();
delay(1000);
close_door();
digitalWrite(LED_PIN,LOW);
break;
case 'b' : digitalWrite(LED_PIN,LOW); // If charecter received is 'b', close the trapdoor
close_door();
break;
case 'c' : digitalWrite(LED_PIN,HIGH); // If charecter received is 'c', open the trapdoor
open_door();
break;
default : digitalWrite(LED_PIN,LOW);
break;
}
}
}
void open_door(){
Serial.println("Opened Door");
servo.write(OPEN_ANGLE); // Send the command to the servo motor to open the trap door
}
void close_door(){
Serial.println("Closed Door");
servo.write(CLOSE_ANGLE); // Send te command to the servo motor to close the trap door
}
Write the code for the front-end and upload it to the Bolt cloud.
<!DOCTYPE html>
<html>
<head>
<title>Pet Feeder</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<style>
.button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
</style>
</head>
<body>
<br>
<button class="button" onclick="dispense_treat()">Feed me!</button>
<script type="text/javascript">
function dispense_treat(){
console.log("Dispensing Treat");
start_communication();
open_door();
setTimeout(2000,close_door());
console.log("Dispensed Treat");
}
function start_communication(){
cmd_serial_begin();
console.log("Init Communication");
}
function open_door(){
cmd_serial_write("a");
console.log("Opened Door");
}
function close_door(){
cmd_serial_write("b");
console.log("Closed Door");
}
function cmd_serial_write(data_val){
$.get("https://cloud.boltiot.com/remote/"+"Your API Key Here"+"/serialWrite?data="+data_val+"&deviceName="+"Your Bolt ID here");
}
function cmd_serial_begin(){
$.get("https://cloud.boltiot.com/remote/"+"Your API Key Here"+"/serialBegin?baud=9600&deviceName="+"Your Bolt ID here");
}
</script>
</body>
</html>
Also, don't forget to associate the page with your product.
Step 5: Deploy the projectOpen your cloud dashboard and open the product associated with your Bolt.
Add pet food (not the mushy kind, but rather the dry treats) from the top of the housing and close it with a lid. Setup someplace comfortable where your pet cannot knock it down and attach a feeding bowl under the trapdoor. Click on the Feed me button and watch your creation dispense food to feed your pet.
If you want to strengthen or modify the design of the housing so that your pet does not chew up the housing, by all means please do so.
Also, if you want to feed your pet using just your voice, head over to this project where I explain you just that.
Comments