Beer crate bottle counter

Last Updated or created 2022-05-07

Post in 2002 due to screenshot .. dont know when i build it, some years before.

Using 24 pushbuttons and a IO expander, i could count the bottles in a crate. Probably used something like a hef4067 ??

Now i probably use a weight sensor or a beer cap counter using a webcam image.

Notification to email and shopping list printer.

Web Interface

Every bottle had to be placed back upside down so the opening of the bottle would not press down on the button. Later i used springs which could hold a empty bottle elevated above the button. The weight of a full bottle would press on the button.

Web part Dopcounter (screenshot at top of page)

<HTML><HEAD><TITLE>dopDB.counter running @ fash's place</TITLE></HEAD><BODY bgcolor=white text=black>
<?
if ($show){
print "<a href='index.php'>Show Last</a>";
}
else {
print "<a href='?show=1'>Show All</a>";
}
?>
<CENTER>
<?
$db = mysql_connect("localhost", "user", "pass");
mysql_select_db("dopDB",$db);
// store voor bargraph
$store=0;
$result2 = mysql_query("SELECT max(timestamp) FROM counter",$db);
$maxtimestamp = mysql_fetch_array($result2);
$result = mysql_query("SELECT * FROM counter",$db);
while ($myrow = mysql_fetch_array($result)) {
$lenght=strlen($myrow[1]);
if ( $lenght = 24)
{
if ($maxtimestamp[0] == $myrow[0] || $show)
 {
 $row1= substr("$myrow[1]", 0, 6);
 $row2= substr("$myrow[1]", 6, 6);
 $row3= substr("$myrow[1]", 12, 6);
 $row4= substr("$myrow[1]", 18, 6);
 $row1 = str_replace("1","<td><img src='dop.jpg'></td>",$row1);
 $row1 = str_replace("0","<td><img src='dopl.jpg'></td>",$row1);
 $row2 = str_replace("1","<td><img src='dop.jpg'></td>",$row2);
 $row2 = str_replace("0","<td><img src='dopl.jpg'></td>",$row2);
 $row3 = str_replace("1","<td><img src='dop.jpg'></td>",$row3);
 $row3 = str_replace("0","<td><img src='dopl.jpg'></td>",$row3);
 $row4 = str_replace("1","<td><img src='dop.jpg'></td>",$row4);
 $row4 = str_replace("0","<td><img src='dopl.jpg'></td>",$row4);
 print "<TABLE border=15 bgcolor='#aaaaaa'><TR>";
 print $row1;
 print "</tr><tr>";
 print $row2;
 print "</tr><tr>";
 print $row3;
 print "</tr><tr>";
 print $row4;
 print "</tr><table>";
 }
$dopcounter=str_replace("0","",$myrow[1]);
$totaldop=strlen($dopcounter);
if ($maxtimestamp[0] == $myrow[0] || $show)
 {
print "<P>";
print date('l dS of F Y H:i:s',$myrow[0]); 
print "<BR><H1>$totaldop bottles left</H1>";
 }
$store = $store + 1;
$storetotals[$store]=$totaldop;
if ($totaldop < 6 && $maxtimestamp[0] == $myrow[0])
 {
 print "<BR>Time to buy some beer again!<BR>";
 }
}
else
{
print "numba bottles error! check code!";
}
}
?>

<table border=0>
<tr>
<?
$storebck=$store;
if ($storebck > 50){ $store=$storebck-50; } else { $store=0; }
while ($store <= $storebck){
print "<td bgcolor=#efefff width=10 valign='bottom'>";
$double=$storetotals[$store]*2;
print "<img src='bar1.gif' width=15 height=$double></td>";
$store = $store +1;
}
?>
</tr>
<tr>
<?
if ($storebck > 50){ $store=$storebck-50; } else { $store=0; }
while ($store <= $storebck){
print "<td bgcolor=#efefff width=10 valign='bottom'>";
print "$storetotals[$store]</td>";
$store = $store +1;
}
?>
</tr>
</table>
</BODY></HTML>
Spread the love