| Electronic Components Datasheet Search |
|
DEV-12887 Datasheet(PDF) 32 Page - SparkFun Electronics |
|
|
|||||||||||||||||||||||||||||
DEV-12887 Datasheet(HTML) 32 Page - SparkFun Electronics |
|
32 / 40 page ![]() /* Electric Imp Web Response Example (device) by: Jim Lindblom SparkFun Electronics date: November 5, 2013 license: Beerware. Use, reuse, and modify this code howeve r you see fit. If you find it useful, buy me a beer some day! The idea for this code was inspired by this gist by indust rialinternet: https://gist.github.com/industrialinternet/5419730 This example code demonstrates how an imp can publish info rmation to a webpage. All of the imp's pins are configured as inputs. T hey can be either digital or analog. There are three parts to this code: 1. The imp (device) code. The imp itself simply reads its pin values, and sends them out to the agent. 2. The agent code. The agent waits for an http request. O n such a request, it'll construct a JSON of the imp's pin values, and re spond with that. 3. An html page to make the http request and handle the re sponse from the agent. There are a number of ways to do this. See one exampl e at the bottom of The agent code. */ /////////// // Setup // /////////// // Register imp. This good practice: imp.configure("Imp Pin Web Response",[],[]); // Configure pins: hardware.pin1.configure(DIGITAL_IN_PULLUP); hardware.pin2.configure(DIGITAL_IN_PULLUP); hardware.pin5.configure(ANALOG_IN); hardware.pin7.configure(DIGITAL_IN_PULLUP); hardware.pin8.configure(DIGITAL_IN_PULLUP); hardware.pin9.configure(DIGITAL_IN_PULLUP); ////////////////////////// // Function Definitions // ////////////////////////// // sendPins reads each of the pins, stores them in a table, an d sends that // table out to the agent. // It calls itself every 100ms 10 times a second. function sendPins() { // Read each of the pins and store them in a table. // The key names "pin1", "pin2", etc. should be kep t the same, unless // you also change them in the device.on() function on th e agent. local pinValues = { Page 32 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 |