Joseph Walston
Created April 1, 2017

Noisy Cricket

A simple office prank circuit to drive your co-workers crazy!

149
Noisy Cricket

Things used in this project

Hardware components

LightBlue Bean
Punch Through LightBlue Bean
×1
Buzzer
Buzzer
×1

Software apps and online services

Punch Through Bean Loader

Story

Read more

Schematics

Noisy Cricket Schematic

Code

Noisy Cricket Sketch

Arduino
Upload to LightBlue Bean using Bean Loader.
/*  Modified from https://punchthrough.com/bean/reference Bean.checkMotionEvent sketch 
*  Noisy Cricket sketch for April Fools Hackster.io Contest 
*  J Walston 
 */ 
int buzzerPin = 3; 
// Create boolean to run loop persistently 
bool motionDetected = false; 
void setup() { 
 // Enable low-g motion events to be detected 
 Bean.enableMotionEvent(ANY_MOTION_EVENT); 
 // Make sure accelerometer is in normal power mode 
 if (Bean.getAccelerometerPowerMode() != VALUE_NORMAL_MODE) { 
   // Set accelerometer power mode to normal 
   Bean.setAccelerometerPowerMode(VALUE_NORMAL_MODE); 
 } 
 // Initially set LED to blank 
 pinMode(buzzerPin, OUTPUT); 
} 
void loop() { 
 // Check for low-g movement 
 if (Bean.checkMotionEvent(ANY_MOTION_EVENT) && !motionDetected) { 
   motionDetected = true; 
 } else if (!Bean.checkMotionEvent(ANY_MOTION_EVENT) && !motionDetected) { 
   Bean.sleep(2);  // Sleep for 2 seconds before rechecking 
 } 
 if (motionDetected) { 
 analogWrite(buzzerPin, 255); 
   delay(1); 
   analogWrite(buzzerPin, 0); 
   delay(1); 
   motionDetected = false; 
 } 
} 

Credits

Joseph Walston

Joseph Walston

1 project • 0 followers

Comments