Things used in this project

Hardware components:
Cutout cortado grande
Punch Through LightBlue Bean
Retain packaging material for easier creation Also an empty container or plastic Easter egg
Software apps and online services:
Punch Through Bean Loader
Ide web
Arduino IDE


egg tossArduino
This code uses the built in accelerometer to judge when the "egg" is broken. It ignores accerlation along the major axis because eggs are much stronger in that direction.
When it detects that the acceleration has reached the breakage threshold, the LED is turned on to indicate game over.

Line 12 maxAccel - maximum acceleration detected along x & y (ignore z acceleration)
Line 13 glow - level to set the LED. Turn on the LED after it breaks
Line 16 Set the accleration range to +- 8g

Line 22 Get the accelerometer reading
Lines 25-27 Determine the magnitude of accerlation not along z-axis (rms method)
Lines 29-32 Update breakage state

Lines 34-35 Display breakage state and set update rate
  This code mimics an egg toss game using the Bean's onboard accelerometer and
  LED. It only considers the X & Y acceleration components as eggs are much
  stronger along the central axis

// define breakVAl for xy Accel that will "break" the egg
#define breakVal 100

AccelerationReading accel;
uint8_t maxAccel = 0;
uint8_t glow = 0;

void setup() {
  // Set accleration range to +- 8g

// Always compare current accleration to max accelration.
// Alert on maximum level
void loop() {
  accel = Bean.getAcceleration();

  // Evaluate acceleration
  uint8_t xA = (abs(accel.xAxis)) / 2;
  uint8_t yA = (abs(accel.yAxis)) / 2;
  uint8_t xyA = sqrt(xA * xA + yA * yA);

  if ( xyA > maxAccel )
    maxAccel = xyA;
  if ( maxAccel > breakVal )
    glow = 110;

  Bean.setLed( glow, glow, glow);


Carol Chesney

Mechanical engineer and teacher



Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback


Similar projects you might like

Get Notified When Door Is Unlocked: LightBlue Bean/Node-Red
  • 291
  • 2

Full instructions

Get notifications by email when your door has been unlocked.

Grove LED Bar Controller with the Bean+
  • 857
  • 14


Learn the basics of using popular Grove components with the new LightBlue Bean+ to get started with building your own projects!

Bluetooth RC
  • 992
  • 15

Work in progress

RC car controlled using BLE.

Hypnos Pendant
  • 1,842
  • 12

Full instructions

A wearable that promotes mindfully spending your time, which also helps trigger lucid dreams.

LightBlue Bean: Arduino Basics
  • 1,286
  • 15


This little Bluetooth board is ideal for wearable tech and tiny robots. Get started with these projects!

Getting Started with Bluetooth Low Energy (BLE)
  • 5,136
  • 18


In this tutorial, we'll learn how to set up BLE GATT services to make a thermometer using Intel's Arduino 101

Add projectSign up / Login