Skip to content

Instantly share code, notes, and snippets.

@bmidgley
Created January 17, 2016 13:58
Show Gist options
  • Save bmidgley/b204151c4a9828e5f3a5 to your computer and use it in GitHub Desktop.
Save bmidgley/b204151c4a9828e5f3a5 to your computer and use it in GitHub Desktop.
lightblue bean balloon payload
/*
Helium balloon payload!
Blink the LED according to the accelerometer setting
Advertise both accelerometer and temperature readings as part of the iBeacon message
*/
void setup()
{
Bean.setBeanName("Orbiter1");
}
void loop() {
int temperature;
int hue;
int x, y, z;
temperature = Bean.getTemperature();
x = Bean.getAccelerationX();
y = Bean.getAccelerationY();
z = Bean.getAccelerationZ();
hue = sqrt(x*x + y*y + z*z);
if(hue >= 255) hue = 255;
Bean.setBeaconParameters(0xA100, hue, temperature + 40);
Bean.setLed(255 - hue, hue, 0);
Bean.sleep(200);
Bean.setLed(0,0,0);
Bean.sleep(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment