Robotica DIY
Published © GPL3+

How to make Arduino EMF ghost detector with LCD

Whenever it detects EMF, LED will Light up and buzzer will make sound until detector is in EMF range.

IntermediateFull instructions provided1 hour3,513
How to make Arduino EMF ghost detector with LCD

Story

Read more

Code

Code snippet #1

Plain text
//RoboticaDIY.com

#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x3F, 16, 2);

int Antenna = A0; 
int val = 0; 
int LED = 11; 
int buzzer = 6;
int high_emf, curr_emf;


void setup() {
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
lcd.begin();
}

void loop() {
val = analogRead(Antenna); 

lcd.setCursor(0, 0);
lcd.print("EMF Level: "); 
lcd.setCursor(11, 0);
lcd.print(val);
lcd.setCursor(0, 1);
lcd.print("Last Hi EMF:");
lcd.setCursor(12, 1);
lcd.print(high_emf);

if(val >= 2){
val = constrain(val, 2, 100); 
curr_emf = val; 
val = map(val, 2, 100, 1, 255); 
analogWrite(LED, val); 
if (curr_emf> high_emf){
high_emf =curr_emf;
}
digitalWrite(buzzer, HIGH); 
delay(100); 
lcd.clear();
}else{ 
analogWrite(LED, 0); 
digitalWrite(buzzer, LOW); 
}

//Serial.println(val); 

}

Code snippet #3

Plain text
lcd.setCursor(0, 0);
lcd.print("EMF Level: ");
lcd.setCursor(11, 0);
lcd.print(val);
lcd.setCursor(0, 1);
lcd.print("Last Hi EMF:");
lcd.setCursor(12, 1);
lcd.print(high_emf);

Code snippet #4

Plain text
if(val >= 2){
val = constrain(val, 2, 100);
curr_emf = val;
val = map(val, 2, 100, 1, 255);
analogWrite(LED, val);

Github

https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library

Credits

Robotica DIY

Robotica DIY

16 projects • 18 followers
Robotica DIY is for those who want to learn themselves. You will get projects on Arduino, Raspberry pi & NodeMcu ESP8266.

Comments