Created
January 17, 2016 13:58
-
-
Save bmidgley/b204151c4a9828e5f3a5 to your computer and use it in GitHub Desktop.
lightblue bean balloon payload
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
/* | |
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