Abstract
The noTone() stops the output of square wave began by tone().
Checks the timer/counter number using by tone() and stops it.
Souce Code
The noTone() is defined in hardware/arduino/avr/cores/arduino/Tone.cpp
|
|
The AVAILABLE_TONE_PINS is set to 1. This is the number of pins that can be used at the same time.
The tone_pin_to_timer_PGM[] is an array that holds timer/counter. Currently only “2” is defined.
The tone_pins[] shows pins which is used by timer/counter, which is related to tone_pin_to_timer_PGM[].
|
|
The input is _pin and its type is uint8_t. There is no output.
Checks if the specified _pin is used. If found, set the timer number to _timer then sets tone_pins[i] to 255 which means unused.
|
|
The pgm_read_byte() is a macro to read one byte from PROGMEM. As the tone_pin_to_timer_PGM is an array, tone_pin_to_timer_PGM+i means the i-th element of the array.
It calls disableTimer() to stop the timer. Then it calls digitalWrite() to stop the output to digital pin.
|
|
At the last it calls digitalWrite(), so the pin which is not used by tone() is specified, the output to the pin is stopped.
Version
Arduino AVR Boards 1.8.6
Last Update
March 21, 2023