Electronic Components Datasheet Search
  English  ▼

X  

DEV-12887 Datasheet(PDF) 24 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) 24 Page - SparkFun Electronics

Back Button DEV-12887 Datasheet HTML 20Page - SparkFun Electronics DEV-12887 Datasheet HTML 21Page - SparkFun Electronics DEV-12887 Datasheet HTML 22Page - SparkFun Electronics DEV-12887 Datasheet HTML 23Page - SparkFun Electronics 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 Next Button
Zoom Inzoom in Zoom Outzoom out
 24 / 40 page
background image
ngly.
// the table input should have parameters 'r', 'g', and 'b'.
// This function will be called by the agent.
function setRGB(rgbValue)
{ 
    bluePin.write(rgbValue.b/255.0);
    redPin.write(rgbValue.r/255.0);
    greenPin.write(rgbValue.g/255.0);
} 
// setUser will print out to the log the name of the LED chang
er
// This function will be called by the agent.
function setUser(suspect)
{ 
    server.log(suspect +" set the LEDs.");
} 
// setTimer will turn the LEDs off after a specified number o
f seconds
// This function will be called by the agent.
function setTimer(time)
{ 
if (time != 0)
        imp.wakeup(time, ledsOff); // Call ledsOff in 'time' s
econds.
} 
///////////////////////////////////
// Important Agent Handler Stuff //
///////////////////////////////////
// Each object that the agent can send us needs a handler, whi
ch we define with
// the agent.on function.  The first parameter in agent.on is 
an identifier 
// string which must be matched by the sending agent. The seco
nd parameter is
// the name of a function to be called. These functions are al
ready defined up
// above.
agent.on("led", setLed);
agent.on("rgb", setRGB);
agent.on("user", setUser);
agent.on("timer", setTimer);
//////////////////////
// Helper Functions //
//////////////////////
// ledsOff just turns all LEDs off.
function ledsOff()
{ 
    ledPin.write(0);
    redPin.write(0);
    greenPin.write(0);
    bluePin.write(0);
} 
The key bit of new code in this example is the agent.on function call. Run
during the setup portion of the code, these function calls set up a handler
function to be called whenever the agent sends a specific string to the imp.
For example, the agent.on("led", setLed); functions says that whenever
a message tagged with an “led” string is received from the agent, call the
setLed() function.
Page 24 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