I'm trying to generate some tones on a piezo speaker via one of the digital output pins. The problem is that I can only get 2.5V output from the digital pin. I've tried several pins and get the same result. Is there some trick to getting the full 5V out?
Here's my code. What is curious is that I can get 5V via digitalWrite() but not via tone().
const int PIEZO_PIN = 11;
void setup() {
pinMode(PIEZO_PIN, OUTPUT);
tone(PIEZO_PIN, 1568, 1000);
delay(1000);
tone(PIEZO_PIN, 2048, 1000);
delay(3000);
digitalWrite(PIEZO_PIN, HIGH);
delay(5000);
digitalWrite(PIEZO_PIN, LOW);
}
void loop() {
// no need to repeat.
}