Tekko BDSimSimulatorProjects

ক্ল্যাপ সুইচ: হাততালি দিলেই বাতি অন-অফClap Switch with Arduino

হাততালির শব্দে microphone board মুহূর্তের জন্য spike করে। নির্দিষ্ট মান পার হলেই relay উল্টে যায়; এক সেকেন্ডের cooldown থাকায় একই হাততালির প্রতিধ্বনি সাথে সাথে আবার বন্ধ করে দিতে পারে না — বিছানার পাশের বাতির ক্লাসিক প্রজেক্ট।

The microphone board spikes for a moment on a clap. A spike above the limit flips the relay; a one-second cooldown means the echo of the same clap cannot flip it straight back — the classic bedside lamp for people who cannot find the switch.

▶ ফ্রি চালিয়ে দেখো / Run it free Parts অর্ডার করো (WhatsApp)

সার্কিট ডায়াগ্রাম · Circuit diagram

Clap Switch with Arduino circuit diagram — Arduino Uno, Sound sensor (microphone), Relay module (5V, 1 channel), Light bulb, Jumper wires

যা যা লাগবে · Parts you need

তার লাগানো · Wiring

Sound sensor (microphone) VCC→Arduino Uno 5V
Sound sensor (microphone) GND→Arduino Uno GND
Sound sensor (microphone) AO→Arduino Uno A0
Relay module (5V, 1 channel) VCC→Arduino Uno 5V
Relay module (5V, 1 channel) GND→Arduino Uno GND
Relay module (5V, 1 channel) IN→Arduino Uno D7
Relay module (5V, 1 channel) COM→Arduino Uno 5V
Relay module (5V, 1 channel) NO→Light bulb a
Light bulb b→Arduino Uno GND.3

Code (Arduino C++)

// Clap switch: the microphone board's AO spikes for a moment on a clap. A spike
// above the limit toggles the lamp through a relay; a one-second cooldown keeps
// the echo of the same clap (or a double clap) from flipping it straight back.
const int mic = A0, relayPin = 7;
const int CLAP = 600;
bool lampOn = false;
long lastClap = -1000;                    // so the very first clap is not swallowed by the cooldown

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

void loop() {
  int raw = analogRead(mic);
  if (raw > CLAP && millis() - lastClap > 1000) {
    lastClap = millis();
    lampOn = !lampOn;
    digitalWrite(relayPin, lampOn ? HIGH : LOW);
    Serial.println(lampOn ? "Lamp ON (clap)" : "Lamp OFF (clap)");
  }
  delay(50);
}

আরো project · More projects