- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
tone() and noTone() in Arduino
The tone function can be used to generate a square wave (50% duty cycle) of a specific frequency on a pin.
The syntax is −
pin is the pin number on which to generate the tone. The frequency is specified in Hz.
This function can also take in a third optional argument − the millisecond duration for which the tone should be generated on the pin.
If you don’t specify the duration, the tone will continue till the noTone() function is called on the same pin. The syntax of the noTone() function is −
where pin is the pin number on which you wish to stop the tone. noTone() will have no effect if there is no tone being generated on the specified pin.
Points to Note
Only one tone can be called at a time, across all pins. Thus, if there is a tone running on pin 6, then trying to generate another tone on pin 5 will have no effect
The minimum frequency for generating tones is 31 Hz. You can’t generate tones of frequencies below that.
The tone() function interferes with the PWM output on pins 3 and 11 (except on the Mega board). It is recommended to not use the two together.
- Distinguish between tone, note, and noise.
- Playing an Arbitrary tone with Android?
- Bitwise AND and OR in Arduino
- Logical AND and OR in Arduino
- pulseIn() and pulseInLong() in Arduino
- shiftIn() and shiftOut() in Arduino
- How to Play an arbitrary tone in Android using Kotlin?
- For and While loops in Arduino
- Square and Square root in Arduino
- Enable and disable interrupts in Arduino
- Reference and dereference operator in Arduino
- How to apply a Sepia tone to an image in Node Jimp?
- Semaphore and Mutex in FreeRTOS using Arduino
- Print new line and tab in Arduino
- Difference between float and double in Arduino