| Electronic Components Datasheet Search |
|
DEV-12887 Datasheet(PDF) 38 Page - SparkFun Electronics |
|
|
|||||||||||||||||||||||||||||
DEV-12887 Datasheet(HTML) 38 Page - SparkFun Electronics |
|
38 / 40 page ![]() document.body.style.backgroundColor = "#FF FFFF"; } else { document.body.style.backgroundColor = "#AA AAAA"; } } }); </script> </head> <body> <h3>Imp Pins:</h3> <div id="pins"> <p> <b>Pin 1:</b> <span id="pin1"><! This is where t he pin 1 reading will go ></span></p> <p> <b>Pin 2:</b> <span id="pin2"><! This is where t he pin 2 reading will go ></span></p> <p> <b>Pin 5:</b> <span id="pin5"><! This is where t he pin 5 reading will go ></span></p> <p> <b>Pin 7:</b> <span id="pin7"><! This is where t he pin 7 reading will go ></span></p> <p> <b>Pin 8:</b> <span id="pin8"><! This is where t he pin 8 reading will go ></span></p> <p> <b>Pin 9:</b> <span id="pin9"><! This is where t he pin 9 reading will go ></span></p> <p> <b>Voltage:</b> <span id="vin"><! This is where the voltage reading will go ></span></p> </body> </html> Before saving and closing the file, edit this line of code to point to your agent’s unique URL: var externalURL ="UpyYpRLmBB7m"; // Put your agent's unique URL here Sweet! Save and open the file with your favorite web browser. Assuming your imp is running with the new device/agent code, you should see something like this: Those 1’s, 0’s, and other numbers might be a little different on your screen. Try pressing a button. Or cover the photocell. Or mess with the imp’s pins in some other way. Are the values changing? How cool is that! The code for this webpage is a little ugly. It uses some web “stuff” that my fragile, electrical engineer mind can barely grasp. There may be a better way to do this, but this works for us. If you find another cool way to request and use data from the imp, let us know in the discussion section! Towards the bottom of the HTML code is a series of <span> tags, with id s like “pin1”, “pin2” etc. But they’re blank. Remember those, they’ll come in handy. The real magic here is happening in the poll() function in the <script> area up top. This function sets up an AJAX) request to the Electric Imp agent. If the request succeeds, function(agentMsg) is executed. This function parses the JSON message received from the agent, and Page 38 of 40 |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |