lbenson
Senior Member
I made some slight changes; j5.html on the PC invoking j5a.js:
j5a.js on the pi:
Here's a pebble representation of what the picaxe would be connected to (I'm not actually using a breadboard; the red module is a mosfet board for PWMing; ESP connection not shown):
Code:
<html><head><link type=text/css rel=stylesheet href=http://192.168.1.144:20780/s.css>
</head><body></body>
<script>var arrayCurVals = [1,1,0,123,"W"];</script>
<script src=http://192.168.1.144:20780/b5a.js></script>
</html>
Code:
document.body.innerHTML = "" +
'<html><head><title> LED Control</title></head>' +
'<body><form name = input method = get>' +
' <font color=blue><font size=5>Picaxe Web Server</font><br><br>' +
' <font color=black>' +
' <table border="1">' +
' <tr><td><input type="radio" id="A" name="L" value="1">LED ON</td>' +
' <td><input type="radio" id="B1" name="L" value="0">LED OFF</td></tr>' +
' <tr><td><input type="radio" id="C" name="P" value="1">PWM ON </td>' +
' <td><input type="radio" id="D" name="P" value="0">PWM OFF</td></tr>' +
' <tr><td><input type="radio" id="E" name="R" value="1">Ramp/Fade ON </td>' +
' <td><input type="radio" id="F" name="R" value="0">Ramp/Fade ' +
' OFF</td></tr></table>' +
'' +
' <p>PWM Duty Cycle:</p>' +
' <input type="text" id="G" name="N"><br><br>' +
'' +
' <p>Select LED:</p>' +
' <input type="radio" id="R" name="X" value="R">Red<br>' +
' <input type="radio" id="Y" name="X" value="Y">Yellow<br>' +
' <input type="radio" id="B" name="X" value="B">Blue<br>' +
' <input type="radio" id="G" name="X" value="G">Green<br>' +
' <input type="radio" id="W" name="X" value="W">White<br>' +
' <input type="radio" id="O" name="X" value="O">Orange<br>' +
'' +
' <br><button type=submit>Submit</button>' +
'</form></body></html> '
var ledStatus = arrayCurVals[0]; // this will be "0"
var pwmStatus = arrayCurVals[1]; //this will be "1"
var pwmRamp = arrayCurVals[2]; //this will be "1"
var pwmDuty = arrayCurVals[3]; //this will be, e.g., "321"
var ledColor = arrayCurVals[4]; // this will be "W"
if (ledStatus == 1) { document.getElementById("A").setAttribute("checked", true); }
else { document.getElementById("B1").setAttribute("checked", true); }
if (pwmStatus == 1) { document.getElementById("C").setAttribute("checked", true); }
else { document.getElementById("D").setAttribute("checked", true); }
if (pwmRamp == 1) { document.getElementById("E").setAttribute("checked", true); }
else { document.getElementById("F").setAttribute("checked", true); }
document.getElementById("G").value=pwmDuty
document.getElementById(ledColor).setAttribute("checked", true);
Here's a pebble representation of what the picaxe would be connected to (I'm not actually using a breadboard; the red module is a mosfet board for PWMing; ESP connection not shown):