| Electronic Components Datasheet Search |
|
DEV-12887 Datasheet(PDF) 23 Page - SparkFun Electronics |
|
|
|||||||||||||||||||||||||||||
DEV-12887 Datasheet(HTML) 23 Page - SparkFun Electronics |
|
23 / 40 page ![]() /* Electric Imp Webcontrolled LEDs by: Jim Lindblom SparkFun Electronics date: November 1, 2013 license: Beerware. Please use, reuse, and modify this cod e. If you find it useful, buy me a beer some day! This is a simple Electric Imp example, which shows how to interface the imp with an agent and webpage. This example code goes handinhand with an HTML webpage. Check out this page for more informatio n: https://learn.sparkfun.com/tutorials/electricimpbreakout hookupguide/example2webcontrol This will show how you can use html color, text, and radi o form inputs to control LEDs on/off, PWM them, and set a timer to turn them off. Circuit: A common cathode RGB LED is connected to the imp's pins 1, 2, and 5. The red anode connects to 1 through a 47 Ohm resistor, gre en 2, and blue 5. The cathode of the LED connects to ground. Another simple, red LED is connected to the imp to imp pi n 9, through another 47 Ohm resistor. The cathode of the LED is grounde d. */ imp.configure("LED Web Control", [], []); // Configure the imp /////////////// // Pin Setup // /////////////// // Setup reference variables for our pins: redPin < hardware.pin1; // R of RGB greenPin < hardware.pin2; // G of RGB bluePin < hardware.pin5; // B of RGB ledPin < hardware.pin9; // Lonely red LED // Configure our pins: ledPin.configure(DIGITAL_OUT); // Simple digital output redPin.configure(PWM_OUT, 0.01, 0); // PWM output 10ms cloc k, off greenPin.configure(PWM_OUT, 0.01, 0); // PWM output 10ms cloc k, off bluePin.configure(PWM_OUT, 0.01, 0); // PWM output 10ms cloc k, off ///////////////////////////////// // Agent Function Declarations // ///////////////////////////////// // setLed will turn the lonely red LED on or off. // This function will be called by the agent. function setLed(ledState) { ledPin.write(ledState); } // setRGB will take a table input, and set the RGB LED accordi Page 23 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 |