Skip to content

Instantly share code, notes, and snippets.

@benwei
Last active December 16, 2015 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benwei/5477365 to your computer and use it in GitHub Desktop.
Save benwei/5477365 to your computer and use it in GitHub Desktop.
blink arduino's led (pin 13) by serial input with char 'a'
-- vi /www/cgi-bin/web2ser -- prepare new file
-- file content below
#!/usr/bin/lua
io.output("/dev/ttyACM0") --
io.write(os.getenv("QUERY_STRING"))
-- after file saved, type command "chmod 755 /www/cgi-bin/web2ser" for correct cgi execute permission
<html>
<body>
<div style="float:left">
<script>
function sendSer(value){
document.getElementById("ser").src="/cgi-bin/web2ser?"+value;
}
</script>
<table>
<tr>
<td>
<input type="button" onmousedown="sendSer('a')" onmouseup="sendSer('a')" value="blink" />
</td>
</tr>
</table>
</body>
</html>
#!/usr/bin/lua
io.output('/dev/ttyACM0')
local step = 0;
while (step < 5) do
io.write('a\r\n')
os.execute('sleep 2')
step=step+1;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment