Hot answers tagged

5

Your amplifier arrangement is fundamentally flawed. At the moment you are "tickling" the top end of the electromagnet in the speaker - that is, you are energising it when the Arduino outputs a HIGH, and leaving it energised to de-energise by itself when the Arduino outputs a LOW. Coupled with that the fact that a PCM file outputs PWM with a carrier ...


2

Have you looked at the Tone library? That does what you want, with some other niceties besides. Anyway, the (or at least "a") problem with your code is that you are leaving the signal LOW almost all the time. You want it to spend half the time high, half the time low: digitalWrite(buzzer, LOW); delayMicroseconds(500000 / frequency); digitalWrite(buzzer, ...


2

You have a timer conflict. tone() uses a timer, and analogWrite() on certain pins uses the same timer. Quite why you're using analogWrite() though, with HIGH (which equates to 1) as the duty cycle I don't quite understand. I would have though digitalWrite() would be a better choice. A duty cycle of 1 would be pretty much invisible anyway...


2

I think it's just a case of startPlayback() being asynchronous. It doesn't block; it doesn't wait for playback to finish. It just sets up the 8000 Hz timer interrupt and returns. The original code calls stopPlayback() when it runs out of samples. You could change that block (under if (sample >= sounddata_length)) to have it cycle on to the next clip, ...


2

The Arduino can supply 5V at max 20mA so 5/0.02 ⇒ 250Ω (if you can find such a beast). NOTE you should use a capacitor to prevent DC flow if using a conventional speaker. In general the larger the speaker the better. Tiny speakers are inefficient transducers. Hi-Fi speakers are not a good choice, as they are often inefficient, trading efficiency for ...


2

No. You can't. That module can only record and play. The only possible thing you could do is record onto the chip then play it back recording it on to the Arduino (at ridiculously low quality) - in which case, what would the point of the chip be? If you want some quality to your recordings you need a powerful microcontroller with an I2S interface and a ...


2

At a guess I would say your main problem is you are defining your TMRpcm objects within the setup and loop functions, which means that as soon as that function exits the TMRpcm objects will be disposed of. I.e., it won't work. It may start playing a sound in setup(), but it will stop (and maybe even crash completely) before you even have a chance to hear it. ...


1

#include "Arduino.h" const byte TONE_PIN = 4; const int ALARM_BEEP_1 = 4186; const int ALARM_BEEP_2 = 4699; const int ALARM_TONE_LENGTH = 200; const int ALARM_TONE_PAUSE = 800; const int ALARM_TONE_REPEAT = 6; boolean alarm = false; void setup() { alarm = true; } void loop() { if (alarm) { alarmSound(); } } void alarmSound() { static ...


1

To effectively drive a speaker from an Arduino you need an amplifier. The good ol' LM386 is a common choice for this (readily available and cheap, though not recommended for battery based projects). While it is possible to drive a speaker directly it's not recommended. Not only is it very quiet, but also it can damage the IO pin. Not only from excess ...


1

As @Juraj mentioned it was solved by changing the setting and I was able easily to play the sound when I matched the setting to this file: So, I could not create one from scratch matches above setting but I was able to convert existing sound through this site which allowed me to convert with desire setting and here finally the exiting sound has matched the ...


1

There are different kinds of buzzers. The simplest one is just a piezoelectric transducer in a plastic casing. You can drive it directly by an arduino pin since its impedance is high. It will work fairly well for high frequencies, but don't expect any bass from it. Another type of buzzer is a piezoelectric transducer connected to a simple oscillator circuit ...


1

Your sample values (that is, the speech[] array) range from 0x00 to 0xfe, using 99.6% of the total range of possible values. Thus, there is no software solution to increase the volume, as you are only 1 bit away from the maximum output level (0xff is the max, and one less is 0xfe). This requires a hardware solution. One easy way is to use a commercial ...


1

As already mentioned in your question, in the Arduino tutorial "Melody" under "Hardware Required" is stated "piezo buzzer or a speaker" and in the comment that heads the sketch is stated: "8 ohm speaker on digital pin 8". But the pictures under "Circuit" and "Schematic" show a piezo sound transducer. In any case the word "buzzer" is wrong. A buzzer usually ...


1

Your breadboard drawing does not show any connection of an audio signal from the Arduino to the amplifier module which is not also connected to a supply rail. Obviously, that cannot work. The only thing that is surprising is that you get even the slightest hint of sound at all. Properly connect your components before you worry about anything else.


1

If you read the documentation for the tone function ( https://www.arduino.cc/en/Reference/Tone ), you might notice this line: Use of the tone() function will interfere with PWM output on pins 3 and 11 (on boards other than the Mega).


1

Only very small ones with 20-30mA. Earbud-size and slightly larger. You can buy a 2x3W amplifier which runs on 5V, and gives you two audio channels - but it works fine for mono. It can drive my 4 ohm desktop speaker, and is probably too powerful for that. Read about signal voltage and resistance for speakers. IIRC small audio outputs (like from an mp3 ...


1

I'm not quite sure I understand the logic of what you're asking. Your description is a little vague. Maybe if you provided more information about what the signals are, what they mean, and where they come from, it may help. However - if you want the melody to play when both inputs are LOW you should change: if(StatOutDoor == LOW && StatInDoor = LOW){...


1

The speaker rating of 8 Ω is AC resistance, speaker impedance. Impedance (AC-Resistance) changes based on the frequency of the signal fed into it. If you are worried about hurting the speaker and need to calculate power driving that particular "load", look at the speaker Wattage rating. Say it is 1 W for example, and you are providing 5&...


1

You might try an audio transformer in the circuit, following a low-pass filter to smooth the PCM signal. Here's a picture of suitable inexpensive transformers (from alexnld.com; but similar transformers are available on Ebay etc.): The effect of the transformer in the circuit is transforming the high voltage, high impedance output of the transistor driving ...


1

Your Arduino UNO won't play any wave file the way you're expecting. There's not enough processing power to do that. In order to play audio using small MCUs such as AVR (or PIC for example) you must use the BTC algorithm. Please, check this out : http://www.radanpro.com/Radan2400/mikrokontroleri/How%20to%20make%20sound%20with%20a%20PIC%20chip.htm and download ...


1

First, since you didn't mention any kind of Arduino, my answer is based on using Arduino Uno/Nano (I think its the most common) 1. Yes you can. You use 1 transistor per building as switch (if there are many LEDs in the building) to gives optimal current and prevent your Arduino pin. The value of R2 -- Rx is depend the LED colour. You can control each group ...


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