Skip to content

Instantly share code, notes, and snippets.

@jbobrow
jbobrow / RingAnimationDebug.ino
Created December 1, 2017 12:24
Looking to have a circular fade rotating at a specific speed of degrees per second.
/*
* Speed up the rotation of LEDs lights or slow down based on button press
*/
#include "blinklib.h"
#include "Serial.h"
ServicePortSerial Serial;
float rotation = 0;
/*
* How to use timers
*
* by Jonathan Bobrow
* 1.25.2018
*/
#include "blinklib.h"
Timer alarm;
@jbobrow
jbobrow / BlinkStepFunction.ino
Created January 27, 2018 17:29
Simplest possible step function example
/*
* Prototype Step Function
*
* A button press sends step from a single Blink
* All Blinks call their step function
*
* Step is special in that it leaves getNeighborState as the value before step happened...
*/
#include "blinklib.h"
@jbobrow
jbobrow / Mortals_Readiness_Test.ino
Last active February 7, 2018 21:53
Not sure why this is failing. Should only light up green when in a configuration of 3 all sharing sides.
/*
* Test of ready state for Mortals
*/
enum State {
DEAD,
ALIVE,
ENGUARDE, // I am ready to attack!
ATTACKING, // Short window when I have already come across my first victim and started attacking
INJURED,
/*
* Take on the color of the dominant Blink attached
*/
byte myState = 0;
Color colors[] = {OFF, BLUE, RED, YELLOW, ORANGE, GREEN};
void setup() {
// put your setup code here, to run once:
setValueSentOnAllFaces( myState );
/*
* RadioLab coin flip
*
* Shows empirically that flipping 100 times and seeing a
* streak of 7 is much more likely than stated in the Stochacity episode
*/
int numberOfTrials = 0; // number of trials (does what it says :)
int numberOfFlipsInTrial = 100; // number of flips in a trial... yeah aptly named
int lengthOfStreak = 7; // how many Tails in a row to make a streak
/*
* RadioLab coin flip
*
* Shows empirically that flipping 100 times and seeing a
* streak of 7 is much more likely than stated in the Stochacity episode
*
* In the show, they mention 14 sets of 7, which is 98 coin flips, with distinct sets
* This is very different than a continuous 100 flips, and much closer to their stated
* 1/6 chance of seeing a perfect run of 7
*/
@jbobrow
jbobrow / SingleFireActions.ino
Created July 18, 2018 21:49
Blinks - Single Fire Action Example
/*
Example of single fire actions
07.18.2018
by Jonathan Bobrow
*/
#include "Serial.h";
@jbobrow
jbobrow / Whackamole_Main_Menu.ino
Created November 8, 2018 05:43
A start for the kind of "attract screen" that whackamole should have...
/*
Mole waiting animation
*/
uint32_t pixelSetTime[6];
uint32_t timeOfPlayerSelection;
Timer popUpTimer;
// number of players
byte numPlayers = 1;
@jbobrow
jbobrow / FlowToFace.ino
Created November 12, 2018 23:57
Blink animation for flowing one direction into another Blink
/*
* Animation Sketch
* Directional flow towards one side of a Blink
*
*/
Timer aniTimer;
#define ANI_DURATION 2000