added first_read to detect baseline accel reading for LED

pull/117/head
alanbjohnston 5 years ago committed by GitHub
parent bbbbad04ab
commit ab43067717
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,12 +19,14 @@ float Sensor2 = 0;
void eeprom_word_write(int addr, int val);
short eeprom_word_read(int addr);
int first_time = true;
int first_read = true;
float T2 = 26.3; // Temperature data point 1
float R2 = 167; // Reading data point 1
float T1 = 2; // Temperature data point 2
float R1 = 179; // Reading data point 2
int sensorValue;
float Temp;
float rest;
void setup() {
@ -99,10 +101,16 @@ void loop() {
if (result == 'R') {
Serial.println("OK");
delay(500);
delay(100);
first_time = true;
setup();
}
else if (result == 'C') {
Serial.println("Clearing stored gyro offsets in EEPROM\n");
eeprom_word_write(0, 0x00);
first_time = true;
setup();
}
if ((result == '?') || first_time == true)
{
first_time = false;
@ -171,7 +179,8 @@ void loop() {
if (result == 'R') {
Serial1.println("OK");
delay(500);
delay(100);
first_read = true;
setup();
}
@ -221,7 +230,12 @@ void loop() {
// Serial.print(" ");
// Serial.println(acceleration);
if (acceleration > 1.2)
if (first_read == true) {
first_read = false;
rest = acceleration;
}
if (acceleration > 1.2 * rest)
led_set(greenLED, HIGH);
else
led_set(greenLED, LOW);

Loading…
Cancel
Save

Powered by TurnKey Linux.