hmkim
Published © GPL3+

Feeding Fish Remotely by a PHPoC Blue

I made a remote fish feeder with PHPoC Blue.

BeginnerShowcase (no instructions)5 hours1,107
Feeding Fish Remotely by a PHPoC Blue

Things used in this project

Hardware components

PHPoC Blue
PHPoC Blue
×1
Servo motor (Tower Pro SG92R)
×1
Feed bucket
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Story

Read more

Schematics

Connection

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

Code

Source code

PHP
index.php
(※ user needs to make init.php to the file system of PHPoC additionally for running this code.)
<?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>

Credits

hmkim

hmkim

1 project • 24 followers

Comments