Electronic Components Datasheet Search
  English  ▼

X  

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

Back Button DEV-12887 Datasheet HTML 16Page - SparkFun Electronics DEV-12887 Datasheet HTML 17Page - SparkFun Electronics DEV-12887 Datasheet HTML 18Page - SparkFun Electronics DEV-12887 Datasheet HTML 19Page - SparkFun Electronics 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 Next Button
Zoom Inzoom in Zoom Outzoom out
 20 / 40 page
background image
/* Digital Input, Analog Input, PWM Output Example 
   by: Jim Lindblom 
   SparkFun Electronics 
   date: July 15, 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! 
   This is a simple piece of code which uses an LED, potentiom
eter, and button. 
   The LED connects to pin 1 through a 47 ohm resistor. The ca
thode of the LED should connect to ground. 
        This means writing pin 1 will turn the LED on, and wri
ting it to 0 turns the LED off. 
   The button connects on one side to pin 9, and the other pi
n of the button goes to ground. 
        We'll use the internal pull­up resistors on pin 9 to b
ias the button high. 
        When the button is pressed, pin 9 should read as low. 
   The wiper of the potentiometer is connected to pin 5. The o
ther two pins of the pot should be 
        connected to +3.3V and GND. This'll make the voltage a
t pin 5 adjustable from 0­3.3V. 
*/
////////////////////////////////////////
// Function definitions               //
////////////////////////////////////////
local ledState =1; // Says local, but think of this as a glob
al var. Start with LED on
// function pin9Changed() will be called whenever pin 9 goes f
rom high­>low or low­>high
function pin9changed()
{ 
    local buttonState = hardware.pin9.read(); // Read from th
e button pin
if (buttonState == 0) // Button will read low if pressed
    { 
        ledState = ledState ? 0: 1;    // Flip flop ledState
        server.log("Button pressed!");
    } 
else // Otherwise button was released, no action
    { 
        server.log("Button released");
    } 
} 
// Loop constantly updates the LED. If ledState is 1, we'll re
ad the pot, and set the LED brightness accordingly.
// If ledState is 0, we'll just turn the LED off. ledState is 
updated in the pin9Changed() function.
function loop()
{ 
if (ledState == 1)
    { 
        local rawValue = hardware.pin5.read();  // Read from t
he potentiometer. Returns a value between 0 and 65535.
        rawValue /= 65535.0;  // Make rawValue a % (and a floa
t). The pin write function requires a value between 0 and 1.
        hardware.pin1.write(rawValue);  // Pin 1 is already co
nfigured as PWM, write potentiometer value 
Page 20 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