0% found this document useful (0 votes)
40 views2 pages

Clap" Prekidač Sa Arduino-M

This document describes a clap switch circuit using an Arduino. The circuit uses an electret microphone, resistors, capacitor, LED, and Arduino. When hands clap near the microphone, it detects the sound and triggers the LED to turn on/off. The Arduino code reads the microphone input, sets a threshold to detect claps, and toggles the LED accordingly.

Uploaded by

Nermin Hadzic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views2 pages

Clap" Prekidač Sa Arduino-M

This document describes a clap switch circuit using an Arduino. The circuit uses an electret microphone, resistors, capacitor, LED, and Arduino. When hands clap near the microphone, it detects the sound and triggers the LED to turn on/off. The Arduino code reads the microphone input, sets a threshold to detect claps, and toggles the LED accordingly.

Uploaded by

Nermin Hadzic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

„CLAP“ PREKIDAČ SA ARDUINO-m

Šema:

Potrebni elementi:
 Mikrofon
 Kondenzator 100nF
 Otpornik 10k
 Otpornik 100k
 Otpornik od 220 Ω do 470 Ω
 LED dioda
 Arduino Uno
 Eksperimentalna pličica i žice za spajanje

Kod za arduino:

//---------------------------------------------------------------------
// Program: clap switch
//
// Description: Switches on an LED when hands are clapped.
// Electret microphone connected to A2, LED and series
// resistor connected to digital pin 2
//
// Date: 6 April 2016 Author: W.A. Smith
// http://startingelectronics.org
//---------------------------------------------------------------------
void setup() {
Serial.begin(9600); // using serial port to check analog
value
pinMode(2, OUTPUT); // LED on digital pin 2
}

void loop() {
int analog_val; // analog value read from A2
static bool led_state = false; // current state of LED

analog_val = analogRead(A2);

if (analog_val > 10) { // trigger threshold


// toggle LED
if (led_state) {
led_state = false; // LED was on, now off
digitalWrite(2, LOW);
Serial.println(analog_val); // print analog value for debug purposes
}
else {
led_state = true;
digitalWrite(2, HIGH); // LED was off, now on
Serial.println(analog_val);
}
delay(50); // wait for clap noise to subside
}
}

You might also like