Do you wanna feed your pets from outdoor? I have made a feeding machine which can be controlled on the browser using smartphone.
What you need to prepare
- Obniz
- Battery or USB adaptor & cable
- Screw and pipe
- Servo motor ( unlimited rotation)
- Pet food - as much as possible
Step 1
Cut pipes and prepare the screw. I made a screw by using 3D printer. Then, connect screw to a motor. and put them into a box.
Step 2
Connect servo motor to obniz.
io0: GND,
io1: VCC,
io2: signal
Then power up your obniz.
Step 3
Write codes below and put food into the bottle. Food will come out from the pipe.
Program
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="https://unpkg.com/obniz@0.1.34/obniz.js"></script>
</head>
<body>
<div id="obniz-debug"></div>
<br>
<div>
<h1> Pet Feeder </h1>
</div>
<button id="meal">Feeding</button>
<div id="dispMeal"></div>
<script>
function getTime(){
var dateTime=new Date();
var hour = dateTime.getHours();
var minute = dateTime.getMinutes();
return hour + ":" + minute;
}
/* This will be over written on obniz.io webapp page */
var obniz = new Obniz("OBNIZ_ID_HERE");
obniz.onconnect = async function () {
var numberOfMeal = 0;
var lastTimeMeal;
$("#dispMeal").text("Number of feeding : "+numberOfMeal)
var servo = obniz.wired("ServoMotor", {gnd:0, vcc:1, signal:2});
$("#meal").click(async function(){
numberOfMeal++
lastTimeMeal = getTime();
$("#dispMeal").text("Number of feeding : "+numberOfMeal+", The last time : "+lastTimeMeal)
servo.angle(0.0);
await obniz.wait(10000);
servo.angle(6.9);
})
}
</script>
</body>
</html>


Top Comments
-
jw0752
-
Cancel
-
Vote Up
+3
Vote Down
-
-
Sign in to reply
-
More
-
Cancel
-
ntewinkel
in reply to jw0752
-
Cancel
-
Vote Up
+3
Vote Down
-
-
Sign in to reply
-
More
-
Cancel
-
jw0752
in reply to ntewinkel
-
Cancel
-
Vote Up
+4
Vote Down
-
-
Sign in to reply
-
More
-
Cancel
-
ntewinkel
in reply to jw0752
-
Cancel
-
Vote Up
+4
Vote Down
-
-
Sign in to reply
-
More
-
Cancel
-
mcb1
in reply to ntewinkel
-
Cancel
-
Vote Up
+5
Vote Down
-
-
Sign in to reply
-
More
-
Cancel
Comment-
mcb1
in reply to ntewinkel
-
Cancel
-
Vote Up
+5
Vote Down
-
-
Sign in to reply
-
More
-
Cancel
Children