Description: A 3-axis accelerometer sits at the heart of this project to provide a nifty little motion detector. Want to know who is stealing from the cookie jar? Want a simple home intrusion detector? Or to test your partner's driving skills? Then have a look at this:
Overlay the Seeed Studio Base Shield onto the Freetronics Eleven (or compatible Arduino).
Use a Universal Cable to attach a Seeed Studio Grove Button to Analog Pin 0 on the Base Shield. The socket is located directly above the Freetronics Eleven Power plug, and next to the Reset button on the Base Shield. Please note that Analog Pin 1 is not used by the Grove Button.
Use a universal Cable to attache a Seeed Studio Grove Buzzer to Analog Pin 1 on the Base Shield. This is the socket next to the one used in Step 2.
Solder the female header pins to the Protoboard. Overlay the protoboard onto the Base Shield to create a third layer. I created this layer to tidy up the project and make it a little bit more portable. You could just wire up another breadboard on the side.
Stick a mini-breadboard (4.5cm x 3.5cm) onto the protoboard. This allows you to use the protoboard for other projects.
Solder the male headers to the 3-axis accelerometer, and then place it centrally onto the breadboard.
You need 5 wires to connect:
GND on protoboard to GND on accelerometer
5V on protoboard to VIN on accelerometer
Analog Pin 3 on protoboard to X on accelerometer
Analog Pin 4 on protoboard to Y on accelerometer
Analog Pin 5 on protoboard to Z on accelerometer
Connect digital pin 8 to an LED and 330 ohm resistor on the breadboard,
Use a wire to connect the resistor mentioned above to GND on the protoboard
Connect the USB cable from your computer to the Freetronics Eleven, and upload the Arduino Sketch to the board.
Disconnect the USB cable, and then power the Freetronics Eleven using a 9V battery and clip.
When you press the button, it will sound 3 warning sounds before it becomes activated.
If it detects a vibration or motion that exceeds the tolerance level, it will alarm. The alarm will continue until you either press the Grove button - which resets and reactivates the device or you can press the Reset button on the Base Shield to Stop monitoring for motion.
//Motion Detector Alarm - Written by ScottC on 2/08/2012
//Global Variables and constants constint buttonPin = A0; // button Pin connected to Analog 0 constint buzzerPin = A1; // buzzer Pin connected to Analog 1
//Accelerometer Pins constint x = A3; // X pin connected to Analog 3 constint y = A4; // Y pin connected to Analog 4 constint z = A5; // Z pin connected to Analog 5
//Alarm LED constint ledPin = 8; // LED connected to Digital 8
int tolerance=20; // Sensitivity of the Alarm boolean calibrated=false; // When accelerometer is calibrated - changes to true boolean moveDetected=false; // When motion is detected - changes to true
//Accelerometer limits int xMin; //Minimum x Value int xMax; //Maximum x Value int xVal; //Current x Value
int yMin; //Minimum y Value int yMax; //Maximum y Value int yVal; //Current y Value
int zMin; //Minimum z Value int zMax; //Maximum z Value int zVal; //Current z Value
void setup(){ //Begin Serial communication Serial.begin(38400);
//Initilise LED Pin pinMode(ledPin, OUTPUT);
}
void loop(){ // If the button is pressed, initialise and recalibrate the Accelerometer limits. if(analogRead(buttonPin)>500){ calibrateAccel(); }
// Once the accelerometer is calibrated - check for movement if(calibrated){ if(checkMotion()){ moveDetected=true; } }
// If motion is detected - sound the alarm ! if(moveDetected){ Serial.println("ALARM"); ALARM(); delay(1000); }
}
//This is the function used to sound the buzzer void buzz(int reps, int rate){ for(int i=0; i<reps; i++){ analogWrite(buzzerPin,900); delay(100); analogWrite(buzzerPin,0); delay(rate); } }
// Function used to calibrate the Accelerometer void calibrateAccel(){ // reset alarm moveDetected=false;
//End of calibration sequence sound. ARMED. buzz(3,40); printValues(); //Only useful when connected to computer- using serial monitor. calibrated=true;
}
//Function used to detect motion. Tolerance variable adjusts the sensitivity of movement detected. boolean checkMotion(){ boolean tempB=false; xVal = analogRead(x); yVal = analogRead(y); zVal = analogRead(z);
// Prints the Sensor limits identified during Accelerometer calibration. // Prints to the Serial monitor. void printValues(){ Serial.print("xMin="); Serial.print(xMin); Serial.print(", xMax="); Serial.print(xMax); Serial.println();
Have you ever wondered if there was a way to store and retrieve data from a USB stick with an Arduino UNO? Most people choose SD cards to store their project data, but you may be surprised there IS a way! IC Station have a nice little module which allows you store and retrieve your Arduino (or other MCU) project data to a USB stick. I am not too sure why USB storage is not widely used in Arduino projects? These modules are not expensive, they have been around for quite a while, and are relatively simple to use. You do not need any libraries to get them to work, however, I must say that documentation for this module is not that easy to find. This site and this document proved to be very useful in my endevour to get this module working, and I hope my tutorial below will help you get started and bridge some of the information gaps. The...
Introduction Nextion is a programmable human machine interface (HMI) that can be customized and designed to simplify the interaction between you and your project. This Nextion Enhanced module (NX4827K043) with a resistive touch screen display, has some additional features not seen in previous traditional versions of the Nextion series. A built in real time clock (RTC) Accessible flash memory (32MB) GPIO functionality Faster clock speed Before you connect the Nextion Enhanced module to your project, you need to design your interface with the free Nextion Editor. The editor can be downloaded here. In this project, I will be designing a simple dynamic interface, which will allow me to interact with a stepper motor in two different ways. The first interface will let me control the direction and speed of the stepper motor through the use of a simple GUI. I will have left and right arrows for the direction, and up and down arrows for the speed. I will also map the Expansion board...
PART THREE If you happened to land on this page and missed PART ONE , and PART TWO , I would advise you go back and read those sections first. This is what you'll find in partone : Downloading and setting up the Android SDK Downloading the Processing IDE Setting up and preparing the Android device Running through a couple of Processing/Android sketches on an Andoid phone. This is what you will find in part two : Introducing Toasts (display messages) Looking out for BluetoothDevices using BroadcastReceivers Getting useful information from a discovered Bluetooth device Connecting to a Bluetooth Device An Arduino Bluetooth Sketch that can be used in this tutorial InputStream and OutputStream We will now borrow some code from the Android developers site to help us to establish communication between the Android phone and the Bluetooth shield on the Arduino. By this stage we have already scanned and discovered the bluetooth device and made a successful connection. We now need to create ...
Comments
Post a Comment