Last active
August 29, 2015 13:59
-
-
Save alexglow/10636889 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| EXAMPLE BUTTON-PUSH PROGRAM FROM JEREMIE | |
| function color { led.setrgb(r,g,b); }; // The function to set the LED to a color | |
| function rotate { r = random(255); g = random(255); b = random(255); color; }; // The function to generate a color and set the LED to it | |
| function startup { pin.makeinputup(2); run rotate,1000; }; // On startup, make digital pin 2 a button. Set the LED to a random color once a second. | |
| function event.button2 { stop *; color; led.gethex("happy"); }; // When button is pushed, stop everything. Set the LED to a random color. Get the current LED color and feed it into function "happy". | |
| function happy { print arg(1):s; mesh.announce(1,arg(1)); }; // Print the hex value just gathered. Send it out to group 1. | |
| function event.group1 { print arg(1):s; led.sethex(arg(1)); }; // When you get a message for group 1, print the message (i.e., the hex color value). Set the LED to that hex value. | |
| So, basically: when the button is pushed on any Scout, set it to a randomly-generated color, then send it out to all the other Scouts, which sets their LEDs to the same color. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment