Skip to content

Instantly share code, notes, and snippets.

@alexglow
Last active August 29, 2015 14:02
Show Gist options
  • Save alexglow/076273f00d323d0742f9 to your computer and use it in GitHub Desktop.
Save alexglow/076273f00d323d0742f9 to your computer and use it in GitHub Desktop.
Pinoccio random-color sync demo
LEAD SCOUT:
function startup { run rotate,1000; };
function rotate { r = random(255); g = random(255); b = random(255); color; };
function color { led.setrgb(r,g,b); message.group(1,led.gethex()); };
FIELD SCOUT(S):
function on.message.group { key.print(arg(3)); led.sethex(arg(3)); };
// Turn the Lead Scout off, then on again - and make sure the Field Scout is also on. Each will flash its torch color when booting. After a brief pause, the Lead Scout will start turning the torch LED random colors once per second, and broadcast them to the Field Scout, which will mirror them.
// If you want to make the Field Scout's code channel-specific:
function on.message.group { if arg(1) == 1 {key.print(arg(3)); led.sethex(arg(3));} };
// See docs at https://docs.pinocc.io/scoutcommands.html#on-message-group
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment