Hot answers tagged

6

I helped someone with a similar question. The results are in my github repo at https://github.com/linhartr22/count. This example uses the PWM library and includes a reference to the article I used to learn how to convert audio files to MP3 with proper settings for the PWM libary. It plays audio through an 8 ohm speaker or a piezo buzzer connected directly to ...


6

I think the problem is in the times you check the sensor. If you clap exactly when you check it will glow even if clapped for 1 ms, but if it checks in between two claps it doesn't detect it. So check more often (reduce the delays) and check for so many sound detections within one second. Or, as JRE below proposes, use an interrupt, this is even better but ...


5

Not really an applause detector, but I have written a sound meter program you could use as a starting point for your own project. It is available here: Arduino sound meter. It works as follows: the analog input is read at a constant rate of about 9600 samples per second, which is normally fine for telephone quality audio processing the DC offset from the ...


5

Interrupts are useful for making things happen automatically in microcontroller programs, and can help solve timing problems. Good tasks for using an interrupt may include reading a rotary encoder, or monitoring user input (like clapping). Using the attachInterrupt() function is the way to go here! https://www.arduino.cc/reference/en/language/functions/...


4

The PCMAudio example shows how to play audio data via PWM. Note that you will need to access the MCU at a low level in order to do this; the Arduino libraries don't provide enough control over the hardware.


4

This project connects the headphones directly to a digital pin. Here is the schematic: I would, however, be more cautious and add a limiting resistor. The output of an Arduino pin should be limited to 20mA as stated here. So, using V=I*R 5 = 0.02 * R R = 5 / 0.02 R = 250ohms So I would add a ~250ohm resistor in series with the head ...


4

I could reproduce the problem with the posted code. This will be caused by the fact that the tone library uses interrupts and has to manually toggle pins, which will always have a bit of jitter. You are better off setting up a hardware timer to generate the tones, this does not require interrupts. For example: #include <TonePlayer.h> TonePlayer ...


3

It is possible to decode DTMF tones with only a few common external components. The trick is to turn the analog audio into a digital signal, and then check the timing between the leading and trailing edges in order to figure out which tone is present. First, create a 1.1V bias using a voltage divider. This bias will connect to both a capacitor that is ...


3

I second BrettAM's comment. The Arduino IDE sets most of all the timers up for PWM, and I had to comment out a section once to use my own ISR with Timer 3 on a 32u4, because no matter where or how I set it, the CTC interrupt never went. The WGM50 and CS51 are set at the start of the Arduino files basically, so that messes with your settings. You will ...


3

Elaborating on JRobert's answer, which I think is definitively the way to go. Here is a typical way of writing a state machine with only three states: No train in the area. You are monitoring the entry sensor. You have detected the train on the entry sensor. You started playing the sound. You are monitoring the exit sensor. You have detected the train on ...


3

A possible solution to your problem can be the following: #include <PCM.h> const unsigned char sample[] PROGMEM = { //Here goes the sample }; int low = 0; int mid = 0; int high = 0; bool first = true; bool second = true; bool third = true; void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { // put your ...


3

Presuming that code is the interior of loop(), your Arduino will spin until a character arrives, that is, until Serial.available()>0 becomes true. It then reads the character with Serial.read() and if it's an 'a' immediately does another Serial.read(). In general, some delay occurs between characters arriving via a serial interface. Whenever the serial ...


3

As John Taylor said, DTMF is not a single tone but two tones transmitted simultaneously, which select the digit from a two-dimensional grid. (Dual tone multi-frequency). This allow 16 possible combinations from only 8 distinct tones. There are chips available specifically for the task of decoding DTMF, but it's always nice to try and find a one-chip ...


3

You can just have a variable that remembers whether the alarm is supposed to be on or off. Let's call it alarm_on. Then: bool alarm_on; static void start_alarm() { alarm_on = true; } static void stop_alarm() { noTone(); alarm_on = false; } void loop() { if (alarm_on) alarm(); if (some_condition()) start_alarm(); if (some_other_condition()) ...


3

Depending on sensor , simple modification with series diode to detect impulse and hold decaying slow with say 0.01uF to and 10 MOhm to 0V will detect 1st time and stretch pulse ~ 0.01u*10M =0.1s


3

As Majenko mentioned in the comment, you created new local arrays in the constructor, but never put anything in the member arrays of the classes. They have the same name, but are not the same variable. Responsible for creating the new variable is the keyword int. However, you cannot simply assign array values by just omitting the int. Therer are multiple ...


2

Yes, you can - see http://www.instructables.com/id/Simple-Wav-Player-Using-Arduino/ Space is quite limited, unless you use an SD card.


2

DTMF is actually two non-harmonically related frequencies transmitted at the same time as opposed to a single frequency tone that can be measured with the above process, hence Dual-Tone-Multi-Frequency: You can use the Rohm BU8872 series devices which decodes the 4 x 4 multi tone combinations directly into a 4 bit digital result per the grid above. This ...


2

Yes, Tim Eckel has already published a library "toneAC" on the Arduino website at http://playground.arduino.cc/Code/ToneAC All of the syntax is there too.


2

Yes, people have done this before, and they have documented it on their own blogs and similar sites. Maybe you should have asked Google first before you came here? You'd most likely have ended up on instructables, where someone has documented exactly what you want to do and how to do it. and saved yourself this entire step.


2

This post was awhile ago, but I wanted to offer some more definitive info for others like myself who were trying to identify it. What you have there is the Keyes KY-037 "high-sensitivity voice sensor" module. Mine came with the Inland Arduino Uno RFID Learning Kit. Apparently the KY-037 and the KY-038 are the same except the KY-037 has a higher sensitivity ...


2

I assume what you actually want is to measure sound intensity. This is significantly more involved than just averaging the samples you read. I have written a few weeks ago a program that does exactly that: it measures the sound intensity and sends those measurements through the serial port. It is a pretty short program (43 lines of code) you may be able to ...


2

As Edgar has mentioned you are confusing things slightly. First there is your sampling frequency. According to the Shannon-Nyquist theorem that is at a minimum of 2x the maximum frequency in your signal. So that is 2x100 = 200Hz. That's the number of samples per second in your sample set. Secondly is your sample size, which is directly related to the FFT ...


2

Nick Gammon already gave a very fine answer about the meaning of the mysterious numbers you were wondering about. Here I am trying to answer only your last question: why manipulate these directly in the first place, because if you reference the source code for analogRead() they look awfully similar. One of the reasons is, as Dave X said in a comment, ...


2

Don't do it. When you say to us: I am very new to DIY; what do I need to buy for such a project? Then you really aren't ready yet. Sometimes a virtuoso or savant exists, and they can make incredible DIY projects, but for most people, jumping into such an aggressive project as your first DIY is a recipe for disaster. I'm not trying to be a smart-ass or ...


2

You will need a processor board, motor driver, sensors, and audio amplifier. Since you are asking on the Arduino forum, it would be natural to consider one of the Arduino boards or derivates - but beware they tend to be rather antiquated compared to alternatives now available. The plus side of the classic ATmega boards is the wide variety of read-to-go ...


2

FYI, these ISD chips sample audio and store a variable charge on a single flash like cell. They do not convert a sample to a numerical value. There is no data to be read from the chips nor (AFAIK) is there an opportunity to write data to play back to the chips. AFAIK, for us common people, each ISD chip needs to have its recording entered individually. Think ...


2

If it's just a clap sound and the background is quiet, then really all you'd need is to sense how loud the sound is. This can be done using an analog comparator interrupt (this is present on the chip itself but not on the Arduino library). If all the uno is doing is measuring the sound and maybe setting an output pin when it's loud, then just poll the ...


2

Both the code and the circuit have problems. In the code: • If the while (buttonState == LOW) loop is ever entered, it will never be left, because buttonState, the controlling variable, does not change within the loop. The simplest fix is to remove the line bool buttonState = digitalRead(buttonPin); and replace while (buttonState == LOW) with while (!...


2

No. That chip can only play files on an SD card that is directly attached to it.


Only top voted, non community-wiki answers of a minimum length are eligible