Electronic Components Datasheet Search
  English  ▼

X  

DEV-12887 Datasheet(PDF) 28 Page - SparkFun Electronics

Part # DEV-12887
Description  Electric Imp Breakout Hookup Guide
PDF  40 Pages
Scroll/Zoom Zoom In 100%  Zoom Out
Manufacturer  SPARKFUN [SparkFun Electronics]
Direct Link  https://www.sparkfun.com/
Logo SPARKFUN - SparkFun Electronics

DEV-12887 Datasheet(HTML) 28 Page - SparkFun Electronics

Back Button DEV-12887 Datasheet HTML 24Page - SparkFun Electronics DEV-12887 Datasheet HTML 25Page - SparkFun Electronics DEV-12887 Datasheet HTML 26Page - SparkFun Electronics DEV-12887 Datasheet HTML 27Page - SparkFun Electronics DEV-12887 Datasheet HTML 28Page - SparkFun Electronics DEV-12887 Datasheet HTML 29Page - SparkFun Electronics DEV-12887 Datasheet HTML 30Page - SparkFun Electronics DEV-12887 Datasheet HTML 31Page - SparkFun Electronics DEV-12887 Datasheet HTML 32Page - SparkFun Electronics Next Button
Zoom Inzoom in Zoom Outzoom out
 28 / 40 page
background image
else if ((colorNibble >= 'a') && (colorNibble <= 'f')) {
return colorNibble ­ 87;
    } 
else if ((colorNibble >= 'A') && (colorNibble <= 'F')) {
return colorNibble ­ 55;
    } 
} 
Check out the comments in the code for a line-by-line dissection. Most of
the code on the agent is an HTTP request handler (the
requestHandler(request, response) function). This function uses a series
of if statements to check for a specific request parameter key (like “led”
or “rgb”). In those if statements, the agent decides what to do with the
parameter value (if anything) and sends a message to the imp using the
device.send function.
With both of those halves of code added to your model, and the circuit built,
build and run the model. Time to test it out!
Testing the Model
After initially running the model, you shouldn’t see anything happen to your
imp or the LEDs it’s connected to. To change that, we need to send an
HTTP request to the agent.
First, we need to locate the URL of our agent, which is printed at the top of
your Agent window. It’ll be something like
https://agent.electricimp.com/0123456789ABCDEF . Each imp gets its
own, unique, agent URL.
How to locate the agent URL. Mine, for example, is
https://agent.electricimp.com/UpyYpRLmBB7m.
We can send requests to the agent by adding URL query strings onto the
agent URL. For example, type
https://agent.electricimp.com/qJx35x_LTITP?led=1 (make sure you
replace my unique code with your own!) into your browser’s address bar
and go. Notice anything happen on your imp circuit? The lonely red LED
should have turned on! Look through the agent code to see what other
parameters we can send.
We can even add multiple parameters to the same request, for example try
going to
https://agent.electricimp.com/qJx35x_LTITP?led=1&rgb=%234080ff&timer=10
in your browser. This request turns on the LED, but it also sends an RGB
string to control the RGB LED and it sets a timer to turn all LEDs off.
This is very cool, but typing these parameters into an address bar is a pain!
Let’s write a simple HTML webpage to take a form input and do all of that
for us!
The HTML Code
This is the last piece to the puzzle – a simple HTML page that takes a form
input, and sends that information out to our Electric Imp agent.
Create a local file on your computer called impControl.html. Open it with a
text editor, and paste the below code into it.:
Page 28 of 40



Html Pages

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40


Datasheet Download

Go To PDF Page


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


Mirror Sites
English : Alldatasheet.com  |   English : Alldatasheet.net  |   Chinese : Alldatasheetcn.com  |   German : Alldatasheetde.com  |   Japanese : Alldatasheet.jp
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