Remote pet feeder

このエントリーをはてなブックマークに追加

How it works

Do you wanna feed your pets from outdoor?
This is a feeder that can be controlled from the Web.

Materials

  1. obniz – 1
  2. battery or usb adaptor & cable – 1
  3. Screw and pipes
  4. Servo motor (unlimited rotation) – 1
  5. Pet food – as many as possible

Step 1

Cut pipes and prepare the screw.
This is a sample stl file. you can download and print this by 3D Printer. http://obniz.io/images/cookbook_3.stl
Then, Build these things and connect screw to a motor.
And put them into a box.

Step 2

Connect Servo motor to an obniz.
like

  1. io0: GND,
  2. io1: VCC,
  3. io2: signal

Then power up your obniz.

Step 3

Write code below.
Put foods to it and Try onece.
foods will be outcome.

Program

<!-- HTML Example -->
<!DOCTYPE html>
<html>
<head> 
  <script src="https://code.jquery.com/jquery-3.2.1.min.js" crossorigin="anonymous"></script>
  
  <script src="https://unpkg.com/obniz@2.0.2/obniz.js"></script>
</head>
 
<body>
  <div id="obniz-debug"></div>
  <br>
  <div class="text-center">
    <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>

Run Now

The html will be opened to run a program.