Trying to code a Volt Meter to act as an analog EMF meter

I've found a cool EMF Code by Aaron Alai he came up with this Code to use a single LED to "Detect" EMF by using the A5 Analog Pin and when I've hooked up the Volt Meter I've got from Sparkfun I had it sometimes max out which is supposed to be starting at 0 volts then reads out the EMF as a voltage.

Here's the Original LED code he done

// Aaron ALAI EMF Detector April 22nd 2009 VERSION 1.0
// aaronalai1@gmail.com
// *future note, put in averaging function to average val which should result in a more
// smooth response from the led.  I will give you a hint on how to make an averaging function;
// it involves the use of an array


int inPin = 5;             // analog 5 
int val = 0;                 // where to store info from analog 5
int pin11 = 11;         // output of red led

void setup() {
 
  Serial.begin(9600);
  
}

void loop() {
  
  val = analogRead(inPin);                    // reads in the values from analog 5 and
                                                                   //assigns them to val
  if(val >= 1){
    
    val = constrain(val, 1, 100);               // mess with these values                                       
    val = map(val, 1, 100, 1, 255);        // to change the response distance of the device
    analogWrite(pin11, val);                    // *note also messing with the resistor should change  
                                                                   // the sensitivity
   }else{                                                     // analogWrite(pin11, val); just tuns on the led with 
                                                                  // the intensity of the variable val
    analogWrite(pin11, 0);                     // the else statement is just telling the microcontroller
                                                                 // to turn off the light if there is no EMF detected
  }
  
 Serial.println(val);                                // use output to aid in calibrating
 
}

I'm gonna use Pin 6 for my Volt Meter so it reads as a EMF known as Miliguass and this would pick it up as a voltage like the REAL one.

is there a way to make it start from 0 volts then max out to 5 volts if it detects a EMF field reading? I've tried modding his code for that and had this with my tricks

// EMF Dectector for Volt Meter v1.0
// 11/7/14
// Coding by SuperScourge A.K.A Christopher Letterle - Doctorsonic@icloud.com
// Made to Detect EMF Fields using a voltage meter & LED
// original code/project by Aaron ALAI - aaronalai1@gmail.com - Credit goes to him for the Code
// without his simple code I couldn't try out my own version of his EMF Detector Code

int inPin = 5; //analog 5
int val = 0;   // where to store info from analog 5
//int pin11 = 11; // output of red LED
// int pin6 = 6;  // Power indicator of LED (Test only - to see if lights up as a power inidcator)
int pin6 = 6; // output of Analog Volt Meter




void setup() {
 
  Serial.begin(9600);

}

void loop() {

  val = analogRead(inPin);
                                
  if(val >=1){   
    
    val = constrain(val, 100, 0);    // mess with these values
    val = map(val, 1, 100, 1, 300); //to the change the response distance of the device
    // analogWrite(pin11, val);       // note also messing with the resistor of the device
    analogWrite(pin6, val);       // should change the sensitivity
                                // analogWrite(pin11, val); just turns on the led with
                               // the intensity of the variable Val
                               // also with my code analogWrite(pin16, val)
                               // does the same as the LED with variable val

  }else{                     // the else statement is just telling the microcontroller

    // analogWrite(pin11, 0);  // to turn off the light if there is no EMF detected
    analogWrite(pin6, 0); // to turn off the volt meter if there's no EMF detected
    
  }

  Serial.println(val);  // use ouput in aid in calibrating
}

it still kinda maxes out instead of starting at 0 volts so it has a good start to detect the EMF Field. - I've just got started with Arudino when I've got it from Sparkfun and mine is the Uno R3

Hi, what arduino are you using, and make sure that the pin you are using as output and going to connect your meter to is a PWM pin.
Not all pins on any of the arduino controllers are capable of PWM output.
What are you using as the input sensor.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Thanks..Tom....... :slight_smile:

the model of Arduino I use the Uno R3 with the Ate Mega chip and here's what I did on Fritzing app

PDF version of Circuit

the Meter isn't the one I have it's those classic square ones I got from SparkFun that goes up to 5 volts DC just use google Drive's Zoom in then zoom in enough to see the pinouts I've used for it.

You need to smooth that output before you can get the meter to read correctly.
http://www.thebox.myzen.co.uk/Tutorial/PWM.html

The whole circuit idea is rather flaky, what do you hope to measure? It will be more affected by your proximity to the wire than anything else.

Miliguass is a measure of magnetic field, that circuit will not measure magnetic fields.

Hi, can I make a suggestion, you post all your pictures and circuits as attachments to the post and not on other online storage facilities.
It makes it difficult for some with limited bandwidth, and usually any pictures get poststamp sized icons in the post.

Tom..... :slight_smile:
I would be putting a 5.1V zener diode, cathode to A0 A5 and anode to gnd, to protect the analogue input pin from being over loaded and causing damage to the arduino.

Hi, can I make a suggestion, you post all your pictures and circuits as attachments to the post and not on other online storage facilities.

Tom it really was not worth looking at. Just a wire out of A5, and a volt meter wired between pin 6 and ground, in a Fritzing mess of a diagram.

Note to PrinceManic - Fritzing sucks do not use it.

Hi, Mike, yes , just getting out of the fetal position now.

Tom..... :slight_smile:

Is this for detecting ghosts?

Hi, you need the sb7 paranormal spirit box.
Tom… :slight_smile:

Grumpy_Mike:
Tom it really was not worth looking at. Just a wire out of A5, and a volt meter wired between pin 6 and ground, in a Fritzing mess of a diagram.

Note to PrinceManic - Fritzing sucks do not use it.

the only app I know, Eagle app I've found is useless to me I tried to find a better app made for Mac as Fritzing is the only choice for now, I'm gonna put this on hold until I could figure this out for sure.

As Aaron made it he used the A5 pin was the antenna and GND pin and a ~pwm pin to make the LED detect a EMF field.

I've messed around with the code and at once I made it to "Appear" to detect EMF in my room, but not sure if that was the case.

but not sure if that was the case.

Yes it was the case. It appeared to detect EMF.

Actually you are using the wrong words. EMF stands for Electro Motive Force and it is more commonly known as "voltage", EMF is measured in volts. It is not an electric field, nor a magnetic field. That circuit is indicating interference, it is not even measuring it because it can't be calibrated to produce an actual measure.

Fritzing is the only choice for now

A much better choice is a pencil and paper, then post a photograph of the results. Fritzing produces a physical layout diagram which is of little use for communicating circuits with others.
Have a look at this:-
http://blog.makezine.com/archive/2011/01/reading-circuit-diagrams.html