DIY alarm with arduino and MMA7361 Accelerometer

To make this diy alarm I use the MMA7361, learn how to use it you can go here.

Arduino code.

#include <AcceleroMMA7361.h>
AcceleroMMA7361 accelero;
//declaration of variables
int x,y,z,a,b,c,time1,time2;
int sensitivity=12;   //i recommend 1-30
long int duration=100000;// duration of the alarm
void setup()
  accelero.begin(13, 12, 11, 10, A0, A1, A2);     //sleep,selftest,0g,g select,x,y,z
  accelero.setARefVoltage(3.3);                   //sets the AREF voltage to 3.3V
  accelero.setSensitivity(LOW);                   //sets the sensitivity to +/-6G
void loop()
  x = accelero.getXAccel();   //get the value of x,y,z
  y = accelero.getYAccel();
  z = accelero.getZAccel();
  a = accelero.getXAccel();
  b = accelero.getYAccel();
  c = accelero.getZAccel();
  if(x-a<-sensitivity || x-a>sensitivity){
  else if(y-b<-sensitivity || y-b>sensitivity){
  else if(z-c<-sensitivity || z-c>sensitivity){
void sound(){ 
      for(int i=1;i<200;i++){


Circuit diagram

In the diagram i don’t show e mini boost converter i used to step up the voltage from 7,5 volt to 27 volt so the speaker would de much louder, I used it only for the speaker. The speaker i used was a 8Ω 0,2W, i didn’t put and resistance in series to limit the current because i wanted to make the speaker as loud as it can get but it might burn up.

3 Comments on “DIY alarm with arduino and MMA7361 Accelerometer

  1. Pingback: Cıvata
  2. Hi there! This post could not be written any better!
    Reading through this post reminds me of my previous room mate!
    He consistently kept talking about this. I ‘ll forward this article to
    him. Quite sure he’ll have a good read. Thank you for sharing!

Leave a Reply

Your email address will not be published. Required fields are marked *