Introduction: Make Electromagnetic /magnetic Field Detector With Arduino

About: Mechatronics engineer Author ( Arduino + Visual Basic 6.0: Make your own software to control Arduino Robots ) Twitter account @ujashpatel

Hello today we are going to learn about electromagnetic / Magnetic Field Detector with Arduino . There is no reason to explain about electromagnetic field or magnetic field . so just start with component you want

List of component

1.arduino board

2.Magnet

3.Piezo electric buzzer

4.Reed switch module

5.general purpose pcb or breadboard

Where to buy this all component ?

Please refer link

"Buzzer module

Funnytoday365 Reed Sensor Module Magnetron Module Reed Switch Switch For Arduino">Reed Switch sensor

MakerBest Hight Quality Compatible Arduino UNO R3 ATmega328P Development Kits">Arduino Uno

Step 1: Connection

Simply we have to connect

Reedswitch

+5 - Arduino 5 v

Gnd - Arduino ground

Signal - Arduino Pin no 12.

Buzzer

+5 - Arduino 5 v

Gnd - Arduino Ground

Signal - Arduino Pin no 3.

Step 2: Program

int out =2; // The speaker is on pin 2

int led = 13;

const int buttonPin = 12; // connect reedswitch sensor

int buttonState = 0; void setup() {

pinMode(buttonPin, INPUT); pinMode(out, OUTPUT); pinMode(led,OUTPUT); }

void loop() { buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {

digitalWrite(led,HIGH); // turn LED on:

}

else

{

digitalWrite(led,LOW);

unsigned char i, j ;

for (i = 0; i <80; i++){ // number of cycles to sound

digitalWrite (out, HIGH); // turn buzzer ON

delay (1) ;// Delay 1ms set frequency 1

digitalWrite (out, LOW); // turn buzzer OFF

delay (1) ;// delay ms

}

for (i = 0; i <100; i++){ // number of cycles to sound

digitalWrite (out, HIGH); // turn buzzer ON

delay (2) ;// delay 2ms set frequency 2

digitalWrite (out, LOW); // turn buzzer OFF

delay (2) ;// delay 2ms

}

} }

Step 3: Working Video