How to Make an Electric Dialer With Speaker on Arduino, for Antique Telephone
by SunFounder Maker in Circuits > Arduino
3765 Views, 12 Favorites, 0 Comments
How to Make an Electric Dialer With Speaker on Arduino, for Antique Telephone
When I was a child, I was curious about everything. One of these questions, was how a telephone worked. Later on, I learned the related knowledge and started another journey - how to make phone by myself.
Well, if you have the same experience, you may be interested to check this basic but interesting tutorial: make a dialer with Arduino (little programming). Not a whole telephone itself, I'm afraid. I'm making this dialer so when making calls with the telephone (not cell phone or nowadays smart phone), I can just pick up the phone receiver and place the speaker near its mic, type in the number on my PC on Serial Monitor of Arduino IDE, and the number will be dialed accordingly. You may think "now who still uses such old telephone". Well, then just for fun!
Prepare the Components
SunFounder Mars/Arduino Uno board http://bit.ly/2tkaMba
USB cable
Speaker
220 Ohm resistor (for current-limiting)
Breadboard http://bit.ly/2slvfrB http://bit.ly/2tXqPZN
Several jumper wires
Connect the Devices
Wire them up: Mars' GND to one pin of the speaker, each of Pin 11 and Pin 12 to a resistor respectively, then the resistors to the other pin of the speaker. In the end, connect the Mars board to the computer with a type-C cable.
Open Arduino IDE, Write the Code and Tone Library, and Run the Program
First write/copy the code in the Arduino IDE (here I use the version 1.8.0).
Include the Tone library. Click Sketch -> Include Library -> Manage Libraries.
On the manager window, type in tone to search (it may take a while to auto-update), find ToneLibrary and click Install.
Then select Tools -> Port and Board. Click the upload icon to burn the code to the Arduino board.
Code can be checked on: https://github.com/sunfounder/Makeitfun/blob/master/diydialer
//This program is written to make a dialer.
#include
String Phone_Number = ""; int i = 0, mark = 0;
//Define freq1 and freq2 as Tone examples, and the frequency in the dual-tone multifrequency (DTMF) //For details of DTMF, refer to https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling Tone freq1; Tone freq2; const int DTMF_freq1[] = {1336, 1209, 1336, 1477, 1209, 1336, 1477, 1209, 1336, 1477}; const int DTMF_freq2[] = {941, 697, 697, 697, 770, 770, 770, 852, 852, 852};
void setup() { Serial.begin(9600); //Define the sound generated at pin D11 and D12 of the Arduino board freq1.begin(11); freq2.begin(12); }
void loop() { //Read data from the serial port, concatenate a Phone_Number string while (Serial.available() > 0) { Phone_Number += char(Serial.read()); delay(2); mark = 1; } //Play the DTMF audio, from Phone_Number, each lasting 200ms with an interval of 300ms PlayDTMF(Phone_Number, 200, 300); //If the number just dailed is received. Since the number has been output, clear it and reset mark if(mark == 1) { Phone_Number = ""; Serial.println(); mark = 0; } }
/* Function of DTMF play Call the format: playDTMF(number(0~9), duration). */ void PlayDTMF(String Number, long duration, long pause) { //If the number entered is null, the duration or pause time is not a positive number, //it's deemed error - stop running at once, return to the main routine. if(Number.length() == 0 || duration <= 0 || pause <= 0) return; //Separate elements in Number for(i = 0; i < Number.length(); i++) { //If Number is a numnber within 0-9, if(Number[i] >= '0' && Number[i] <= '9') { //ASCII minus 0, then a pure number is got, Number[i] -= '0'; //The number will be output in the serial monitor for convenient check Serial.print(Number[i], DEC); //output one DTMF freq1.play(DTMF_freq1[Number[i]], duration); //output a second DTMF freq2.play(DTMF_freq2[Number[i]], duration); delay(pause); } }
}
Power on and "Dial" the Phone Number
Power on the circuit by the USB cable connected to the computer. Open Serial Monitor in the IDE and enter the phone number on the window.
Then the speaker will dial the number you entered. Place the telephone receiver mic near the speaker, and the phone will dial automatically. Saved the rotary panel! Since the modern smart phones cannot dial, we can test only. Hit the Call on the mobile phone, tap out a tele number and enter the same one on the serial window. Listen, the same sound!
BTW, I found that if the resistor is removed, the speaker will make louder sounds. But, that's not so safe in protecting the speaker. So be cautious when trying.