Skip to main content
4 votes

Won't break out of for loop

An int can't hold 1000000. It is a signed 16-bit variable, which means it can only hold between -32768 and +32767. To store larger numbers you need to use long, or unsigned long which are signed and ...
Majenko's user avatar
  • 105k
4 votes
Accepted

everything works independitly but not together. Piezo not generating a tone

You connected the piezo to pin 1? Chose other pin. Pin 1 is Serial TX. You 'pump' PWM to USB. tone() function will make sound no matter if you have a delay there. You set 1 sec with 1000 as third ...
Juraj's user avatar
  • 18k
4 votes
Accepted

Noise on piezo analog read due to Arduino power supply

The 9V wall adapter is in most cases a switched power regulator with a high frequency. That's like a radio transmitter direct beside the wire. So there is nothing mystical, when the smooth USB Voltage ...
Peter Paul Kiefer's user avatar
3 votes
Accepted

Passive buzzer works with analogWrite(), but not with digitalWrite(). It also has constant static noise

To sound a passive buzzer, use Arduino tone() function. If you set the pin HIGH the piezo surfaces are pulled together (or pulled away). It is what makes one click but nothing more. To make a tone the ...
Juraj's user avatar
  • 18k
2 votes
Accepted

Amplify Piezo Sensor

You write, The blog post mentions a 0.1uf capacitor in the hand-drawn sketch but the Fritzing diagram shows a 10uf capacitor. I am using the 10uf capacitor. The Fritzing diagram in the high-...
James Waldby - jwpat7's user avatar
2 votes
Accepted

How do I make specific tones with a piezo buzzer?

It's very hard to know from your question what you are having trouble with. I have a piano and I can hit the keys, but it takes me a long time to hit them in the right order and with the right ...
Mark Smith's user avatar
  • 2,181
2 votes
Accepted

Why is the piezo buzzer not making any sound?

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 ...
James Waldby - jwpat7's user avatar
2 votes
Accepted

Multiple tones with one piezo buzzer

First of all - You can drain max 20mA via pin, when one of the pins is HIGH and the other LOW, there is 5V between them, so there should be at least 250 Ohm resistor placed there, if you do not want ...
gilhad's user avatar
  • 1,420
2 votes
Accepted

How to stop a loop when using attachInterrupt to catch the change of a button

The key will be to split up playCarMusicStart and instead create a playCarMusicStep that will do just one iteration of the loop and returns. Call it every time in loop() akin to blinkWithoutDelay. In ...
ratchet freak's user avatar
2 votes
Accepted

Execute function until called again?

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 ...
Edgar Bonet's user avatar
  • 43.3k
2 votes

Serial monitor doesn't work with piezo buzzer

Pin D10 of NodeMcu is io 1 which is RX pin of Serial interface of the esp8266. Serial is on NodeMCU connected to USB. The pin is on board labeled RX. D8 is boot config pin io 15. It must have ...
Juraj's user avatar
  • 18k
2 votes
Accepted

how to set buzzer on and off

When I have a state-machine problem such as this, I diagram it first - here's mine, based on how I understand your requirements: Most state machines are only activated when an external event happens, ...
JRobert's user avatar
  • 15.3k
2 votes

Won't break out of for loop

In addition to Majenko's answer (an int on this platform can't hold a number greater than 32767) you have a second problem. You are evidently trying to make a middle C tone (261.6 Hz) by toggling a ...
Nick Gammon's user avatar
  • 38.4k
1 vote

Including keypad library removes sound from my piezo element

I was able to solve it , piezo dissent work in pin 9 but works when connected to pin 13.
Rhea Ramtohul's user avatar
1 vote

Noise on piezo analog read due to Arduino power supply

In addition to what Peter Paul Kiefer suggests, you will also want to place an RC low-pass filter, between the piezo transducer, and the analog input. You mention that you'll be sampling this value ...
John R. Southern's user avatar
1 vote

Passive buzzer works with analogWrite(), but not with digitalWrite(). It also has constant static noise

Your code example does not work because you have a PASSIVE buzzer. Your example would work okay with an ACTIVE buzzer. With a passive buzzer you must turn on/off the digital I/O pin at the desired ...
Jeff Wahaus's user avatar
1 vote

Passive buzzer works with analogWrite(), but not with digitalWrite(). It also has constant static noise

One thing to note about the digital write part. While you have a delay between the HIGH to LOW, there is no delay to go back to HIGH (other than the time to leave loop and re-enter; which can be very ...
Makuna's user avatar
  • 11
1 vote

Using 2 piezo buzzers to emit the same tone with phase difference

For a very simple example you can do something like this: #define SPEAKER1_PIN 5 #define SPEAKER2_PIN 6 void setup() { pinMode(SPEAKER1_PIN, OUTPUT); pinMode(SPEAKER2_PIN, OUTPUT); } void ...
Jeff Wahaus's user avatar
1 vote

Using 2 piezo buzzers to emit the same tone with phase difference

Since the frequency is so low, you can generate the signals in software. That would not be as clean as timer-generated signals, but it will be much easier. And probably clean enough for the intended ...
Edgar Bonet's user avatar
  • 43.3k
1 vote
Accepted

Arduino play many piezo at once

Use the Timer library. You can attach up to 10 events to each Timer object you declare. That will suit your use case.
Enric Blanco's user avatar
  • 2,114
1 vote

How can I read a piezo sensor and have it output a fixed voltage?

If the piezo is mounted to a surface, and you're hitting the surface to create vibrations, it is complicated as mentioned in the other answer, and it would be a good idea to connect piezo brass to a ...
Lights4Music's user avatar
1 vote

How can I read a piezo sensor and have it output a fixed voltage?

A piezo will output a decaying sinusoid when you feed it an impulse (a hit on the attached surface). Problem with a high frequency sinusoid is that one: half the time it's negative, and two: it forces ...
Orotavia's user avatar
  • 171
1 vote

Amplified piezo sensor wiring problem

You don't seem to understand how to wire an OP-AMP. Here is a quick tutorial on their basics: https://www.youtube.com/watch?v=kqCV-HGJc6A The thing is that you are missing a LOT of resistors. An ...
Dat Ha's user avatar
  • 2,913
1 vote

Piezo not loud enough

Alternatively there are COTS parts (Common Off The Shelf) which are simpler to use and may satisfy your requirements. This is just the 1st one I found (search for "5 volt piezo buzzer"). Of course ...
st2000's user avatar
  • 7,340
1 vote

Piezo not loud enough

The device you pictured seems to be a switch-mode power module which will output 10V DC. Get rid of it before you do any damage. You don't post any link to data, but I assume you mean the Transducer ...
Milliways's user avatar
  • 1,645
1 vote
Accepted

Is a 9v battery appropriate for a piezo and 1 LED?

A couple things to note: Get rid of the PWR LED on the Trinket so it's not always drawing current. Sleep the MCU whenever possible, only waking on interrupts. Converting 9V to 5V with an LDO (in this ...
uint128_t's user avatar
  • 819

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