Vernier Software and Technology
Vernier Software & Technology
Arduino and Vernier Sensors

Turn on a Buzzer Based on a Motion Detector Reading

The Motion Detector can be used to make a simple alarm system by slightly modifying the VernierLibDemoMotionDetector sketch. This code turns on line 13 when the Motion Detector reads a distance less than 100 centimeters.

#include "VernierLib.h" 
VernierLib Vernier;
float distance = 0;// distance in cm 
void setup()
{
  Serial.begin(9600);
  Serial.print("Motion Detector reading...");
}

void loop()
{
  distance = Vernier.readMotionDetector();
  Serial.print(distance);
  Serial.println(" cm");
  delay(100);//delay a tenth of a second
}

Contents

Introduction

Vernier Engineering Contest

Vernier recognizes instructors for creative uses of Vernier sensors to introduce engineering concepts and/or practices. Vernier Engineering Award »

Go to top