Skip to content

Issue with tone() on Arduino UNO Wifi #13

Closed
@lemio

Description

@lemio

This code wouldn't make a sound on a regular piezo, nor make a signal on the oscilloscope

void setup() {
  pinMode(6, OUTPUT);
}

void loop() {
  delay(1000);
  tone(6,600);
  delay(100);
  noTone(6);
}

While this code does work:

void setup() {
  pinMode(6, OUTPUT);
}

void loop() {
  tone(6,600);
  delay(100);
  noTone(6);
  delay(1000);
}

This code also works:

void setup() {
  pinMode(6, OUTPUT);
}

void loop() {
  delay(1000);
  tone(6,600);
  tone(6,600);
  delay(100);
  noTone(6);
}

Would there be a way to fix it in the https://github.com/arduino/ArduinoCore-megaavr/blob/master/cores/arduino/Tone.cpp file? It seems like delay(x) leaves some timer in a state that tone can't deal with. Other functions like delayMicroseconds() seem to work with tone without any problems...

I use version 1.6.24 in the board manager, tried different Arduino UNO Wifi's and selecting ATMEGA328 register emulation doesn't influence the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions