Things used in this project

Hardware components:
Cutout cortado grande
Punch Through LightBlue Bean
×1
Adafruit industries ada1536 image
Buzzer
×1
826 04
Male/Female Jumper Wires
×2
Hero ipad family 2015 2x
Apple iPad
Or iPhone or computer. WiFi access is needed to compile code.
×1

Schematics

Buzzer circuit
Connect it to digital pin 0 and ground.
Uomrxrv7gynkeg4dplph

Code

Example code: "BeanBlink"C/C++
Arduino demo code from the Bean Loader app.
/* 
  This sketch uses the Bean library to blink the on-board RGB LED. 
  
  Notes:
    - This is not a low-power sketch 
    - A Bean with a low battery might show a faint blue and green LED color
  
  This example code is in the public domain.
*/

void setup() {
}

void loop() {
  // Turn the Bean's LED red
  Bean.setLed(255, 0, 0);
  Bean.sleep(1000);      
  // Turn the Bean's LED green  
  Bean.setLed(0, 255, 0);
  Bean.sleep(1000);
  // Turn the Bean's LED blue
  Bean.setLed(0, 0, 255);
  Bean.sleep(1000);
  // Turn off the Bean's LED
  Bean.setLed(0, 0, 0);
  Bean.sleep(1000);
}
Example code: "AccelerationLed"C/C++
Arduino sample code from the Bean Loader app.
/* 
  This sketch reads the acceleration from the Bean's on-board 
  accelerometer and displays it on the Bean's LED.
    
  This example code is in the public domain.
*/

void setup() {
  // Optional: Use Bean.setAccelerationRange() to set the sensitivity 
  // to something other than the default of ±2g.
}

// the loop routine runs over and over again forever:
void loop() {
   // Get the current acceleration with range of ±2g, 
   // and a conversion of 3.91×10-3 g/unit or 0.03834(m/s^2)/units. 
   AccelerationReading accel = Bean.getAcceleration();

   // Update LED color
   uint16_t r = (abs(accel.xAxis)) / 4;
   uint16_t g = (abs(accel.yAxis)) / 4;
   uint16_t b = (abs(accel.zAxis)) / 4;
   Bean.setLed((uint8_t)r,(uint8_t)g,(uint8_t)b);

   Bean.sleep(50);
}
Speaker codeC/C++
Produces a buzzer tone at approximately 500 Hz, on digital pin 0.
int spk = 0;

void setup() {
  pinMode(spk, OUTPUT);
}

void loop() {
  analogWrite(spk, 255);
    delay(1);
    analogWrite(spk, 0);
    delay(1);
}
Handy BLE Colors exampleC/C++
Example code by P.D. Shelley, for the Handy BLE app. See https://github.com/pdshelley/ColorsExample/blob/master/ColorsExample/ColorsExample.ino
/*
  ColorsExample
  For use with the "Handy BLE" iPhone app by Paul Shelley and 
  the LightBlue Bean by Punchthrough Design.
  This sketch receives Serial data with a simple packet format
  of '#' for a start character and ';' as an end character. Start
  and end characters can be changed easily. Simple error checking 
  is also included. 
  
  Handy BLE - https://pdshelley.com
  LightBlueBean - https://punchthrough.com
  This example code is in the public domain.
  Created 9 June 2015
  by Paul Shelley
*/

String command;
boolean commandStarted = false;

void setup() {
  Serial.begin();
}

void loop() {
  getCommand();
}

/* 
This function reads the serial port and checks for the start character '#'
if the start character if found it will add all received characters to 
the command buffer until it receives the end command ';' When the end 
command is received the commandCompleted() function is called.
if a second start character is found before an end character then the buffer
is cleared and the process starts over. 
*/
void getCommand() {
   while (Serial.available()) {
    char newChar = (char)Serial.read();
    if (newChar == '#') {
      commandStarted = true;
      command = "\0";
    } else if (newChar == ';') {
      commandStarted = false;
      commandCompleted();
      command = "\0";
    } else if (commandStarted == true) {
      command += newChar;
    }
  }
}

/*
This function takes the completed command and checks it against a list
of available commands and executes the appropriate code.  Add extra 'if' 
statements to add commands with the code you want to execute when that 
command is received. It is recommended to create a function for a command
if there are more than a few lines of code for as in the 'off' example.
*/
void commandCompleted() {
  if (command == "red") {
    Bean.setLed( 255, 0, 0 );
    Serial.print("LED turned red");
  }
  if (command == "green") {
    Bean.setLed( 0, 255, 0 ); 
    Serial.print("LED turned green");
  }
  if (command == "blue") {
    Bean.setLed( 0, 0, 255 );
    Serial.print("LED turned blue");
  }
  if (command == "yellow") {
    Bean.setLed( 255, 255, 0 );
    Serial.print("LED turned yellow"); 
  }
  if (command == "orange") {
    Bean.setLed( 255, 60, 0 ); 
    Serial.print("LED turned orange");
  }
  if (command == "purple") {
    Bean.setLed( 128, 0, 128 );
    Serial.print("LED turned purple");
  }
  if (command == "white") {
    Bean.setLed( 255, 255, 255 );
    Serial.print("LED turned white");
  }
  if (command == "off") {
    off();
  }
}

/*
Use a separate function like this when there are more than just a few
lines of code.  This will help maintain clean easy to read code.
*/
void off() {
  Bean.setLed( 0, 0, 0 );
  Serial.print("LED turned off");
}

Credits

Photo on 7 5 17 at 5 06 pm 7 05huowsyxv
Alex Glow

The Hackster team's resident Hardware Nerd. I like robots, music, EEG, wearables, and languages. FIRST Robotics kid.

Contact

Replications

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

Comments

Similar projects you might like

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

Full instructions

Get notifications by email when your door has been unlocked.

Grove LED Bar Controller with the Bean+
Easy
  • 856
  • 14

Protip

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

Electronic Egg Toss Game
Easy
  • 618
  • 13

The classic picnic game is messy, but this version will let you practice indoors.

Bluetooth RC
Easy
  • 991
  • 15

Work in progress

RC car controlled using BLE.

Hypnos Pendant
Easy
  • 1,840
  • 12

Full instructions

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

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

Protip

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