Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // *Arduino Phone Dialer*
- // Uses the pulse dialing method to dial a phone number.
- int offtimer = 60; // The higher the number, the slower the timing.
- int ontimer = 30;
- int phone_number[] = {
- 0,1,7,6,9,0,8,3,0,0}; // the phone number to dial
- int number_length = 9; // the number of digits in the phone number (i.e. the length of the array)
- int out=12; // the output pin to the pulsing relay
- int didthis=0;
- void setup() {
- pinMode(out, OUTPUT); // define pin as output.
- }
- void loop() {
- // do this once
- if (didthis == 0) {
- digitalWrite(out, HIGH); // turn on the relay to establish a connection to the phone (i.e. plugging in the phone)
- delay (1000);
- // loop through the phone numbers
- for (int count = 0; count <= number_length; count++) {
- delay (1000); // delay after every number dialed
- switch (phone_number[count]) {
- case 1:
- // If the number to be dialed is 1, pulse once.
- digitalWrite(out, LOW); // turn the relay OFF
- delay(offtimer); // wait for a while
- digitalWrite(out, HIGH); // turn the relay ON
- delay(ontimer); // wait for a while
- break;
- case 2:
- // If the number to be dialed is 2, pulse twice.
- for (int repeat = 0; repeat < 2; repeat++) {
- digitalWrite(out, LOW); // turn the relay OFF
- delay(offtimer); // wait for a while
- digitalWrite(out, HIGH); // turn the relay ON
- delay(ontimer); // wait for a while
- }
- break;
- case 3:
- // If the number to be dialed is 3, pulse thrice.
- for (int repeat = 0; repeat < 3; repeat++) {
- digitalWrite(out, LOW); // turn the relay OFF
- delay(offtimer); // wait for a while
- digitalWrite(out, HIGH); // turn the relay ON
- delay(ontimer); // wait for a while
- }
- break;
- case 4:
- // If the number to be dialed is 4, pulse 4 times.
- for (int repeat = 0; repeat < 4; repeat++) {
- digitalWrite(out, LOW); // turn the relay OFF
- delay(offtimer); // wait for a while
- digitalWrite(out, HIGH); // turn the relay ON
- delay(ontimer); // wait for a while
- }
- break;
- case 5:
- // If the number to be dialed is 5, pulse 5 times.
- for (int repeat = 0; repeat < 5; repeat++) {
- digitalWrite(out, LOW); // turn the relay OFF
- delay(offtimer); // wait for a while
- digitalWrite(out, HIGH); // turn the relay ON
- delay(ontimer); // wait for a while
- }
- break;
- case 6:
- // If the number to be dialed is 6, pulse 6 times.
- for (int repeat = 0; repeat < 6; repeat++) {
- digitalWrite(out, LOW); // turn the relay OFF
- delay(offtimer); // wait for a while
- digitalWrite(out, HIGH); // turn the relay ON
- delay(ontimer); // wait for a while
- }
- break;
- case 7:
- // If the number to be dialed is 7, pulse 7 times.
- for (int repeat = 0; repeat < 7; repeat++) {
- digitalWrite(out, LOW); // turn the relay OFF
- delay(offtimer); // wait for a while
- digitalWrite(out, HIGH); // turn the relay ON
- delay(ontimer); // wait for a while
- }
- break;
- case 8:
- // If the number to be dialed is 8, pulse 8 times.
- for (int repeat = 0; repeat < 8; repeat++) {
- digitalWrite(out, LOW); // turn the relay OFF
- delay(offtimer); // wait for a while
- digitalWrite(out, HIGH); // turn the relay ON
- delay(ontimer); // wait for a while
- }
- break;
- case 9:
- // If the number to be dialed is 9, pulse 9 times.
- for (int repeat = 0; repeat < 9; repeat++) {
- digitalWrite(out, LOW); // turn the relay OFF
- delay(offtimer); // wait for a while
- digitalWrite(out, HIGH); // turn the relay ON
- delay(ontimer); // wait for a while
- }
- break;
- case 0:
- // If the number to be dialed is 0, pulse 10 times.
- for (int repeat = 0; repeat < 10; repeat++) {
- digitalWrite(out, LOW); // turn the relay OFF
- delay(offtimer); // wait for a while
- digitalWrite(out, HIGH); // turn the relay ON
- delay(ontimer); // wait for a while
- }
- break;
- }
- }
- }
- didthis=1;
- digitalWrite(out, HIGH); // turn the relay ON to keep the phone on the line and wait for the other end to ring.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement