Skip to content

Instantly share code, notes, and snippets.

@jenschr
Last active October 15, 2023 11:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jenschr/a199aabfac4750d3311882aaa1c84165 to your computer and use it in GitHub Desktop.
Save jenschr/a199aabfac4750d3311882aaa1c84165 to your computer and use it in GitHub Desktop.
Basic HTML page for talking to Particle Photon
<!-- Turn on/off eight LEDs connected to Particle Photon pins D0...D7 -->
<!DOCTYPE>
<html>
<head>
<title>on/off</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script type="text/javascript">
function submitform( formNum )
{
var dataObj = {};
dataObj.args = formNum;
// the first string of random chars is the ID of your Photon. You can find this via build.particle.io by clicking the devices icon
// the second string (access_token) can be found under the Settings icon. When you regenerate the token, all former versions cease to work
$.post( "https://api.particle.io/v1/devices/28002c001847341128333633/toggle?access_token=124ae13ec936ee7d6fb5e633787cf8d207287d62", dataObj, function( dataObj ) {
$( "#result" ).html( JSON.stringify(dataObj) );
});
return false;
}
</script>
</head>
<body>
<center>
<div>
<a href="javascript: submitform(1)">- 1 -</a>
<a href="javascript: submitform(2)">- 2 -</a>
<a href="javascript: submitform(3)">- 3 -</a>
<a href="javascript: submitform(4)">- 4 -</a>
<a href="javascript: submitform(5)">- 5 -</a>
<a href="javascript: submitform(6)">- 6 -</a>
<a href="javascript: submitform(7)">- 7 -</a>
<a href="javascript: submitform(8)">- 8 -</a>
<a href="javascript: submitform(10)">- off -</a>
</div>
<div id="result"></div>
</center>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment