Close

Finally, a library!

A project log for Detecting Motion With AC/Static Electricity

Using only a single wire to increase sensitivity, an Arduino's ADC can be used to detect motion!

lixie-labsLixie Labs 08/23/2016 at 07:161 Comment

Hello everyone! Back in May 2016, I released this video demonstrating using the Arduino's ADC to detect motion of nearby living things. Since then I've been very busy with other projects like the Emotiscope and Volume Library, but I've returned to this code to library-ize it!

Before I continue, let me clear up some things I've learned since then:

Once you've installed the Buzz library from GitHub or the Arduino Library Manager, usage is as simple as this:

#include "Buzz.h" // Include the Volume library
Buzz buzz;

void setup() {
  Serial.begin(115200);
  buzz.begin(A0,60,3000);
}
void loop() {
  Serial.println(buzz.level());
  delay(1);
}

Also included with the library is an example ("basic.ino") that allows you call your own functions when motion exceeds a custom threshold! This allows for alarm-type actions! For example:

#include "Buzz.h"

Buzz buzz;

void setup() {
  Serial.begin(115200);
  pinMode(13, OUTPUT);

  buzz.begin(A0,60,3000);
  buzz.setAlarm(soundTheAlarm, 20, 500);
}
void loop() {
  buzz.checkAlarm();
  buzz.printData();
  delay(1);
}
void soundTheAlarm(){
  // Generates an alarm sound
  for(byte i = 0; i < 128; i++){
    tone(speaker,880);
    delay(1);
    tone(speaker,440);
    delay(1);
  }
  noTone(speaker);
}

Feel free to try the Buzz Library for yourself, and let me know how things go!
https://github.com/connornishijima/arduino-buzz

- Connor Nishijima

Discussions

Mike Atencio wrote 05/14/2018 at 01:42 point

Love the cat static strap. Doubt my cats would either.

  Are you sure? yes | no