This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
|
oak:tutorials:particle-function [2016/03/24 18:52] jwhendy finished up code sections |
oak:tutorials:particle-function [2016/03/24 19:46] jwhendy [Code] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== Oak: using Particle.variable() ===== | + | ===== Oak: using Particle.function() ===== |
| - | + | ||
| - | [[http://digistump.com/wiki/_media/oak-rgb-led.png|{{http://digistump.com/wiki/_media/oak-rgb-led.png?400}}]] | + | |
| This tutorial is very similar to the one on [[http://digistump.com/wiki/oak/tutorials/particle-variable|Particle.variable()]]. This time, however we will be doing the reverse: //sending// data to the Oak. To accomplish this, we use ''Particle.function()''. As an example, we will send ''POST'' commands using ''curl'' to the Particle API which will control the color of an RGB led connected to the Oak. | This tutorial is very similar to the one on [[http://digistump.com/wiki/oak/tutorials/particle-variable|Particle.variable()]]. This time, however we will be doing the reverse: //sending// data to the Oak. To accomplish this, we use ''Particle.function()''. As an example, we will send ''POST'' commands using ''curl'' to the Particle API which will control the color of an RGB led connected to the Oak. | ||
| Line 18: | Line 16: | ||
| |Resistor, 220 ohm| 3 | Red-Red-Brown| | |Resistor, 220 ohm| 3 | Red-Red-Brown| | ||
| - | These are the same components used with the [[http://digistump.com/wiki/oak/tutorials/rgb-led#components_used|advanced LED tutorial]]. Feel free to substitute any resistor value between 100-1k ohms. | + | These are the same components used with the [[http://digistump.com/wiki/oak/tutorials/rgb-led#components_used|RGB LED tutorial]]. Feel free to substitute any resistor value between 100-1k ohms. |
| **Note:** You need to install [[https://curl.haxx.se/download.html|curl]] to push data to the Particle API. | **Note:** You need to install [[https://curl.haxx.se/download.html|curl]] to push data to the Particle API. | ||
| Line 207: | Line 205: | ||
| Particle.function("set", set_rgb); | Particle.function("set", set_rgb); | ||
| | | ||
| - | // we'll configure the on-board LED to blink | + | // initialize each color pin as an output |
| - | // this is handy for simply making sure the Oak is running your sketch | + | |
| pinMode(6, OUTPUT); | pinMode(6, OUTPUT); | ||
| pinMode(7, OUTPUT); | pinMode(7, OUTPUT); | ||