Pls check this arduino code for earth quake detector

djsfantasi

Joined Apr 11, 2010
9,156
I would have, had you attached the code. As it is, I can't read .rar files nor am I going to an unknown link.

Attach the code and give us a detailed description of the error message.
 

Thread Starter

rijoe.mathew

Joined Sep 21, 2014
42
This is the code:

C:
#include <EEPROM.h>

#include <EEPROM.h>
#include "EEPROMAnything.h"
#include <LiquidCrystal.h>


const int alarmPin = 5;
const int relayPin = 10;
int Xacc, Yacc, Zacc, threshold = 0, thresholdSET = 25;
long debouncing_time = 15; //Debouncing Time in Milliseconds
volatile unsigned long last_micros;
LiquidCrystal lcd(12, 11, 9, 8, 7, 6);
struct sensorValue
{
int X;
int Y;
int Z;
};

sensorValue acceleration;

void debounceInterrupt_Increment()
{
if ((long)(micros() - last_micros) >= debouncing_time * 1000) {
IncrementThreshold();
last_micros = micros();
}
}

void debounceInterrupt_Decrement()
{
if ((long)(micros() - last_micros) >= debouncing_time * 1000) {
DecrementThreshold();
last_micros = micros();
}
}
void IncrementThreshold() {
thresholdSET = EEPROM.read(500);
thresholdSET++;
EEPROM.write(500, thresholdSET);
}

void DecrementThreshold() {
thresholdSET = EEPROM.read(500);
thresholdSET--;
EEPROM.write(500, thresholdSET);
}

void setup() {
lcd.begin(16, 2);
attachInterrupt(0, debounceInterrupt_Increment, RISING);
attachInterrupt(1, debounceInterrupt_Decrement, RISING);
pinMode(alarmPin, OUTPUT);
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, HIGH);
EEPROM.write(500, thresholdSET);
digitalWrite(alarmPin, LOW);
lcd.setCursor(0, 0);
lcd.print("Initializing....");
delay(5000);
sensorValue acceleration = { analogRead(A0) , analogRead(A1) , analogRead(A2) };
EEPROM_writeAnything(0, acceleration);
EEPROM_readAnything(0, acceleration);
lcd.clear();
}

void loop() {
EEPROM_readAnything(0, acceleration);
threshold = EEPROM.read(500);
lcd.setCursor(0, 0);
lcd.print("Monitoring Mode");
lcd.setCursor(0,1);
lcd.print("Threshold = ");
lcd.print(threshold);
Xacc = analogRead(A0);
Yacc = analogRead(A1);
Zacc = analogRead(A2);

if ((Xacc >= (acceleration.X + threshold)) || (Xacc <= (acceleration.X - threshold))||(Yacc >= (acceleration.Y + threshold)) || (Yacc <= (acceleration.Y - threshold))||(Zacc >= (acceleration.Z + threshold)) || (Zacc <= (acceleration.Z - threshold))) {
digitalWrite(relayPin, LOW);
digitalWrite(alarmPin, HIGH);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("ALARM !!!!!");
lcd.setCursor(0,1);
lcd.print("PLEASE EVACUATE");
delay(5000);
digitalWrite(relayPin, HIGH);
digitalWrite(alarmPin, LOW);
lcd.clear();
}


}
Moderators note: used code tags for C
 
Last edited by a moderator:

ebeowulf17

Joined Aug 12, 2014
3,307
Are the include statements supposed to have some names in quotes and others in brackets? Looks weird to me, but I'm not sure either way. No time to look it up right now.
 

djsfantasi

Joined Apr 11, 2010
9,156
Why are you including the EEPROM library twice? Cut one include out. Are you sure the EEPROMAnything library is compatible with EEPROM?

Some names in quotes and some in brackets make sense. One is a local dir and the other is the public dir. I can't look up which one is what right now.
 

djsfantasi

Joined Apr 11, 2010
9,156
Im getting an EPROM error
Please include the error. My crystal ball is in the shop. Something with this much detail would be helpful:
Code:
In file included from sketch_jul13b.cpp:2:
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:2:46: error: Arduino.h: No such file or directory
In file included from sketch_jul13b.cpp:2:
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h: In function 'int EEPROM_writeAnything(int, const T&)':
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:6: error: expected initializer before '*' token
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:9: error: 'p' was not declared in this scope
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h: In function 'int EEPROM_readAnything(int, T&)':
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: 'byte' was not declared in this scope
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: 'p' was not declared in this scope
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: expected primary-expression before ')' token
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: expected primary-expression before 'void'
 

djsfantasi

Joined Apr 11, 2010
9,156
Im getting an EPROM error
Please include the error. My crystal ball is in the shop. Something with this much detail would be helpful:
Code:
In file included from sketch_jul13b.cpp:2:
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:2:46: error: Arduino.h: No such file or directory
In file included from sketch_jul13b.cpp:2:
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h: In function 'int EEPROM_writeAnything(int, const T&)':
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:6: error: expected initializer before '*' token
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:9: error: 'p' was not declared in this scope
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h: In function 'int EEPROM_readAnything(int, T&)':
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: 'byte' was not declared in this scope
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: 'p' was not declared in this scope
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: expected primary-expression before ')' token
C:\arduino-0023\libraries\EEPROM/EEPROMAnything.h:15: error: expected primary-expression before 'void'
 
Top