Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano Metal Detector with Loudspeaker Alert

View and Edit Project In Cirkit DesignerImage of Arduino Nano Metal Detector with Loudspeaker Alert

Circuit Documentation

Summary

This circuit is designed to detect the presence of metal using a metal detector module and provide audio feedback through a loudspeaker. The circuit is controlled by an Arduino Nano microcontroller, which processes the input from the metal detector and drives the loudspeaker accordingly. A resistor is used to limit the current to the loudspeaker.

Component List

  1. Loudspeaker

    • Description: Converts electrical signals into sound.
    • Pins: pin1, pin2
  2. Resistor

    • Description: Limits the current in the circuit.
    • Pins: pin1, pin2
    • Properties:
      • Resistance: 200 Ohms
  3. Metal Detector

    • Description: Detects the presence of metal objects.
    • Pins: VCC, GND, D
  4. Arduino Nano

    • Description: Microcontroller used to control the circuit.
    • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK

Wiring Details

Loudspeaker

Resistor

Metal Detector

Arduino Nano

Code Documentation

Arduino Nano Code

#include <Talkie.h>
#include <Vocab_US_Large.h>
#include <Vocab_Special.h>

const int sensorPin = 2;
const int speakerPin = 3;

// The message said by (TTS)
const uint8_t openMessage[] = {sp2_IS, sp2_S, sp2_O, sp2_P, sp2_E, sp2_N};
const uint8_t closeMessage[] = {sp2_IS, sp2_S, sp2_C, sp2_L, sp2_O, sp2_S, sp2_E, sp2_D};

// Previous sensor state 
int lastState = LOW;

Talkie voice;

void setup() {
  pinMode(sensorPin, INPUT);
  pinMode(speakerPin, OUTPUT);
}

void loop() {
  int presentState = digitalRead(sensorPin);

  // Detecting change in state
  if (presentState == HIGH && lastState == LOW) {
    voice.say(openMessage);
  }

  // Detecting change (closed)
  if (presentState == LOW && lastState == HIGH) {
    voice.say(closeMessage);
  }

  lastState = presentState;
  delay(10); // default 
}

This code is designed to read the state of the metal detector and provide audio feedback through the loudspeaker. When the metal detector detects metal, the Arduino Nano will play a pre-defined "open" message. When the metal detector no longer detects metal, the Arduino Nano will play a pre-defined "closed" message. The Talkie library is used for text-to-speech functionality.