In this chapter, we can use the Arduino Tone Library. it is nothing but an Arduino Library, which produces square-wave of a specified frequency (and 50% duty cycle) on any Arduino pin. A duration can optionally be specified, otherwise the wave continues until the stop() function is called. The pin can be connected to a piezo buzzer or a speaker to play the tones.
Warning − Do not connect the pin directly to any audio input. The voltage is considerably higher than the standard line level voltages, and can damage sound card inputs, etc. you can use a voltage divider to bring the voltage down
You will need the following components −
Follow the circuit diagram and make the connections as shown in the image given below.
Open the Arduino IDE software on your computer. Coding in the Arduino language will control your circuit. Open a new sketch File by clicking New.
To make the pitches.h file, either click the button just below the serial monitor icon and choose "New Tab", or use Ctrl+Shift+N.
Then paste the following code –
Save the above given code as pitches.h
The code uses an extra file, pitches.h. This file contains all the pitch values for typical notes. For example, NOTE_C4 is middle C. NOTE_FS4 is F sharp, and so forth. This note table was originally written by Brett Hagman, on whose work the tone() command was based. You may find it useful whenever you want to make musical notes.
You will hear musical notes saved in the pitches.h. file.
Arduino Related Interview Questions
|IBM-REXX Interview Questions||Flash Interview Questions|
|Computer Hardware Interview Questions||Software Engineering Interview Questions|
|PLC/Microcontrollers/Microprocessors Interview Questions||IBM Integration Bus Interview Questions|
|Continuous Integration Interview Questions||C preprocessor Interview Questions|
|8051 Microcontroller Interview Questions||TCS Technical Interview Questions|
|Wipro Technical Interview Questions||Wipro Java Interview Questions|
|Fieldbus Interview Questions||Universe Designer Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.