Control a program from a web page.





 To the page where the web options are.



Now you need to choose and option.


[code]
  <html>
<title> Offshore Educators (Main Page) </title>
 <title> lights </title>
 <body bgcolor="aquamarine">
    <CENTER><h2><B><I>Test PPort</I></B></h2></CENTER>

Press a button to perform an action

    <form ACTION="kitt.php" method="post">
    <p>
    <input type="submit" value="Kitt">
    </form>
    <p>
    <form ACTION="rnd.php" method="post">
    <p>
    <input type="submit" value="Random">
    </form>
    <form ACTION="allon.php" method="post">
    <p>
    <input type="submit" value="All led's on">
    </form>
    <form ACTION="alloff.php" method="post">
    <p>
    <input type="submit" value="All Led's off">
    </form>

<form ACTION="test.php" method="post">
    <p>
    <input type="submit" value="Send">
    </form>

<hr>
<a href="http://oeorgan1"> Click on me to return to the homepage!</a>
</body>
</html>
[/code]

Now the code to run the application and then go back to the web page.

[code]

<?php
echo exec('/usr/bin/kitt');
header("Location: http://oeorgan1/pport/index.html");
exit;
?>
[/code]


After you compile your executable you, you must copy the file to  /usr/bin/ and then

$ sudo chmod +x kitt

for php to use the code

The leds  should be showing an led sequence.


-------------------------------------------------


You will need some leds to show of the lights. This gets connect to a legacy printer port. Probably only pin 18 needs to be connected to ground.


You also need the code to control the lights. that goes into /usr/bin

Code for kitt.bas  (compile with fbc -lang qb kitt.bas)

[code]
 dim duration as double
dim tim as double
tim = TIMER
duration = .3
out 888, 0
for y = 1 to 20
'rem up
for x = 0 to 6
out 888, 2^x
r= inp(888)
out 888, (2^(x+1) +r)
tim = TIMER
DO
LOOP UNTIL (TIMER - tim + 86400) - (INT((TIMER - tim + 86400) / 86400) * 86400) > duration
out 888, 0
next x
'rem down
for b = 1 to 7
z = 7 - b
out 888, 2^z
r= inp(888)
out 888, (2^(z+1) +r)
tim = TIMER
DO
LOOP UNTIL (TIMER - tim + 86400) - (INT((TIMER - tim + 86400) / 86400) * 86400) > duration
out 888, 0
next b
next y
'rem end of sequence
out 888,0
[/code]


#!/bin/sh
# Parallel port CGI script
#
# Send HTTP headers
echo Content-type: text/html;charset=ISO-8859
echo
# Do the controlling
/usr/bin/kitt1
# Output web page data
echo "<html><head></head><body>"
echo "Parallel port controlled<bights Kittr>"
echo "<a href=\"/pport/index.html\">Go back to controlling page</a>"
echo "</body></html>"
#

Comments

Popular posts from this blog

Guiless?

MSOffice vs Libreoffice

Raspberry pi zero.