This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
oak:tutorials:particle-function [2016/03/24 19:44] jwhendy |
oak:tutorials:particle-function [2016/05/27 01:30] (current) pfeerick edited to hopefully reduce confusion on how Particle.function is used in code |
||
---|---|---|---|
Line 26: | Line 26: | ||
This function creates an interface between your Oak and particle.io. We create a function with a given name, and then access that named function via ''curl'' commands, passing along a value with it. On the Oak side, it finds the function with that name, and then runs it with the value that was passed. | This function creates an interface between your Oak and particle.io. We create a function with a given name, and then access that named function via ''curl'' commands, passing along a value with it. On the Oak side, it finds the function with that name, and then runs it with the value that was passed. | ||
- | The syntax looks like this: | + | The syntax looks like ''Particle.function("name", function_name)'', and you then have a function that look like the below example, which is run when the function is triggered. You would normally place the ''Particle.function'' command in the setup() portion of your code. Have a look at the example sketch at the bottom of the page to better understand how function is used. |
<code> | <code> | ||
- | Particle.function("name", function_name) | ||
- | |||
int function_name(String arg) | int function_name(String arg) | ||
{ | { | ||
Line 205: | Line 203: | ||
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); |