arduino_mdee.zip
this is what i have been working on so far it works quite well, im looking for some help in improving it i have had no luck in trying to add a pizo buzzer the EM off it just disrupts the sensitivity
the buttons are just 5v supply with 10k resistor to ground
when calibrating just use the delay, if its not calibrated right the numbers up and down wont match just switch it up and down again
then adjust the sensitivity the lower the more sensitive it will get (SN)
adjusting the delay is like what it says it will wait a few microseconds before sampling well as long as what you set it for basicly find the sweet spot lol
i tryed a few things on the site but none seemed to work so i had to try my self, its easy to build and uses minimal components and should be easy to use other OP amps
Code:
#include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); int Coil = 13; // the number of the Coil pin int led = 10; // detection led can add a buzzer here int analogPin = 0; // pin to read the samples int cSamples = 30; // how much samples are taken int SampleDelay = 0; // delay before gathering the samples ajustable via the buttons int SampleCounter = 0; int tempc = 0; int Sensor = 5; // default sensor offset ajustable via buttons int testresults = 0; int cal = 0; // store the calibration setting float val = 0.0f; float readSamples = 0.0f; float results = 0.0f; bool calibrate = false; int button_up_Sensor = 7; int button_down_Sensor = 6; int button_up_SampleDelay = 9; int button_down_SampleDelay = 8; void setup () { lcd.begin(16, 2); pinMode(Coil, OUTPUT); pinMode(led, OUTPUT); pinMode (A0, INPUT); Serial.begin (115200); } void loop () { digitalWrite(Coil, HIGH); delayMicroseconds(50); // how long the gate is open to charge the coil digitalWrite(Coil, LOW); delayMicroseconds(SampleDelay); for(int i = 0; i < cSamples; i++) { val = analogRead(analogPin); readSamples+=val; val = 0.0f; } results = (readSamples/cSamples); if(results < 0.0f) { results = fabsf(results); // if the results are - flip them to + } if(SampleCounter <= cSamples) { tempc += (int)results; // recast to a int easy to deal with the display SampleCounter++; }else { if(calibrate == false) { cal = tempc/cSamples; calibrate = true; lcd.setCursor(0, 1); lcd.print(" "); lcd.setCursor(0, 1); lcd.print("Cal "); lcd.print(cal); } testresults = tempc/cSamples; lcd.setCursor(0, 0); lcd.print(" "); lcd.setCursor(0, 0); lcd.print("DP "); lcd.print(testresults); digitalWrite(led, LOW); if(cal > (testresults + Sensor) || cal < (testresults - Sensor)) digitalWrite(led, HIGH); tempc = 0; SampleCounter = 0; } readSamples = 0.0f; if(digitalRead(button_up_Sensor) == HIGH) { Sensor++; lcd.setCursor(8, 0); lcd.print(" "); lcd.setCursor(8, 0); lcd.print("SN "); lcd.print(Sensor); digitalWrite(Coil, LOW); delay(200); } if(digitalRead(button_down_Sensor) == HIGH) { Sensor--; lcd.setCursor(8, 0); lcd.print(" "); lcd.setCursor(8, 0); lcd.print("SN "); lcd.print(Sensor); digitalWrite(Coil, LOW); delay(200); } if(digitalRead(button_up_SampleDelay) == HIGH) { SampleDelay++; lcd.setCursor(8, 1); lcd.print(" "); lcd.setCursor(8, 1); lcd.print("SamD "); lcd.print(SampleDelay); digitalWrite(Coil, LOW); calibrate = false; delay(100); } if(digitalRead(button_down_SampleDelay) == HIGH) { SampleDelay--; if(SampleDelay < 0)SampleDelay = 0; lcd.setCursor(8, 1); lcd.print(" "); lcd.setCursor(8, 1); lcd.print("SamD "); lcd.print(SampleDelay); digitalWrite(Coil, LOW); calibrate = false; delay(100); } }
the buttons are just 5v supply with 10k resistor to ground
when calibrating just use the delay, if its not calibrated right the numbers up and down wont match just switch it up and down again
then adjust the sensitivity the lower the more sensitive it will get (SN)
adjusting the delay is like what it says it will wait a few microseconds before sampling well as long as what you set it for basicly find the sweet spot lol
i tryed a few things on the site but none seemed to work so i had to try my self, its easy to build and uses minimal components and should be easy to use other OP amps
Comment