def RunBlink():
os.system('sudo ./home/pi/ledblink.py')
In my html directory I have 'index.html':
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
p://
www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>WebIOPi | LED and Python-script Control</title>
<script type="text/javascript" src="/webiopi.js"></script>
<script type="text/javascript">
webiopi().ready(function() {
button = webiopi().createMacroButton("macro", "Backup", "RunBackup");
$("#controls").append(button);
button = webiopi().createMacroButton("macro", "Blink", "RunBlink");
$("#controls").append(button);
button = webiopi().createGPIOButton(25, "LED");
$("#controls").append(button);
webiopi().refreshGPIO(true);
});
</script>
<style type="text/css">
button {
display: block;
margin: 5px 5px 5px 5px;
width: 200px;
height: 45px;
font-size: 24pt;
font-weight: bold;
color: white;
}
</style>
</head>
<body>
<div id="controls" align="left"></div>
</body>
</html>
and in /home/pi I have 'ledblink.py':
#!/usr/bin/env python
import time
import RPi.GPIO as gpio
ledpin=18
gpio.setmode(gpio.BCM)
gpio.setup(ledpin,gpio.OUT)
try:
while 1:
gpio.output(ledpin,1)
time.sleep(0.5)
gpio.output(ledpin,0)
time.sleep(0.5)
except KeyboardInterrupt:
gpio.cleanup()
gpio.cleanup()
Can anyone here help me further?
Thanks in advance
Jean