Feeding fish remotely by a PHPoC Blue

Feeding fish remotely by a PHPoC Blue

Postby Amy » Fri Nov 20, 2015 5:54 pm

I used to worry about my lovely fish for feeding them when I'm away.
So I decided to make a remote feeder with PHPoC Blue.

Here are the items I used.

Item
Servo motor(Tower Pro SG92R)


Feed bucket



Installation



Connection
[Servo motor] ---- [PHPoC Blue]
Yellow ---- HT0
Red ---- PWR5
Brown ---- GND



How to feed
It is simple.
I installed a servo motor attached a feed bucket with a hole on top in the above my fish tank.
The servo motor can rotate 180 degrees.
The hole faced upwards in normal state but when I pressed the button at the web page I made, the servo turned upside down to let the fish eat.


Web page
When you press the button, the servo motor runs.




Source Code
index.php
Code: Select all

<?php
include_once 
"/lib/sd_340.php";
 
define
("PWM_PERIOD", 20000); // 20000us (20ms)
define("WIDTH_MIN", 500);
define("WIDTH_MAX", 2500);
 
$status 
= _POST("status");
            
if 
($status == "on")
{
    ht_pwm_setup(0, WIDTH_MIN, PWM_PERIOD, "us");
 
    $width 
= WIDTH_MIN; 
    ht_pwm_width
(0, $width, PWM_PERIOD);
 
    sleep
(3);
 
    $width 
= WIDTH_MAX ; 
    ht_pwm_width
(0, $width, PWM_PERIOD);
}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo system("uname -i");?></title>
<link rel="icon" href="favicon.ico" type="images/x-icon" />
<link rel="shortcut icon" href="favicon.ico" type="images/x-icon" />
<meta content="initial-scale=0.7, minimum-scale=0.5, width=device-width, user-scalable=yes" name="viewport">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<style type="text/css">
 <!--
#btn {background-image:url('off.png'); width:95px; height:94px; }
#btn:active {background-image:url('on.png'); width:95px; height:94px; }
-->
</style>
<script type="text/javascript">
function feed_control()
{
    main.status.value = "on";
    main.submit();    
}
</script>
</head>
 
<body>
<form name="main" method="post" value="">
<input type="hidden" name="status">
    <center><br /><br /><br />
        <h2>Fish feeder</h2><br /><br /><br /><br />
        <div id="btn" onclick="feed_control()"></div>
    </center>
</form>
</body>
</html>



Video

phpBB [video]



You can also see this project in hackster.io web site.
https://www.hackster.io/hmkim/feeding-fish-remotely-by-a-phpoc-blue-724eec
Last edited by Amy on Wed Mar 29, 2017 1:32 pm, edited 7 times in total.
Amy
 
Posts: 13
Joined: Wed May 14, 2014 5:37 pm

Re: Feeding fish remotely by a PHPoC Blue

Postby DavidKwon » Fri Nov 20, 2015 5:55 pm

It looks good ! :D
I think you can add more functions like setting the time for feeding.
DavidKwon
 
Posts: 3
Joined: Fri Jul 31, 2015 4:26 pm

Re: Feeding fish remotely by a PHPoC Blue

Postby Amy » Fri Nov 20, 2015 5:58 pm

DavidKwon wrote:It looks good ! :D
I think you can add more functions like setting the time for feeding.


Thank you for your good idea. :)
Amy
 
Posts: 13
Joined: Wed May 14, 2014 5:37 pm

Re: Feeding fish remotely by a PHPoC Blue

Postby Gerard » Sun Mar 12, 2017 4:49 am

Hi Amy,

I used your fishfeeder code and trying to run it, but unfortunatly it gives an init.php error (I am a newbie fyi)
I am making a feeder for racing pigeons to be fed multiple times a day with different types of food.
Can you help me out?
Gerard
 
Posts: 1
Joined: Tue Apr 05, 2016 10:48 am

Re: Feeding fish remotely by a PHPoC Blue

Postby Amy » Mon Mar 13, 2017 9:39 am

Gerard wrote:Hi Amy,

I used your fishfeeder code and trying to run it, but unfortunatly it gives an init.php error (I am a newbie fyi)
I am making a feeder for racing pigeons to be fed multiple times a day with different types of food.
Can you help me out?


I've tested this souce code without any problem. I think you didn't make init.php.
PHPoC searches init.php file after booting. If PHPoC fails to find a file named init.php, it does not run any code. Therefore, you need to make or upload init.php to the file system of PHPoC.
Amy
 
Posts: 13
Joined: Wed May 14, 2014 5:37 pm


Return to Project

Who is online

Users browsing this forum: No registered users and 1 guest

cron