Advertisement
Guest User

Arduino Pulse Dialer

a guest
Apr 4th, 2013
5,744
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. // *Arduino Phone Dialer*
  2. // Uses the pulse dialing method to dial a phone number.
  3.  
  4. int offtimer = 60; // The higher the number, the slower the timing.
  5. int ontimer = 30;
  6. int phone_number[] = {
  7. 0,1,7,6,9,0,8,3,0,0}; // the phone number to dial
  8. int number_length = 9; // the number of digits in the phone number (i.e. the length of the array)
  9. int out=12; // the output pin to the pulsing relay
  10. int didthis=0;
  11.  
  12. void setup() {
  13. pinMode(out, OUTPUT); // define pin as output.
  14. }
  15.  
  16. void loop() {
  17. // do this once
  18. if (didthis == 0) {
  19. digitalWrite(out, HIGH); // turn on the relay to establish a connection to the phone (i.e. plugging in the phone)
  20. delay (1000);
  21.  
  22. // loop through the phone numbers
  23. for (int count = 0; count <= number_length; count++) {
  24. delay (1000); // delay after every number dialed
  25. switch (phone_number[count]) {
  26. case 1:
  27. // If the number to be dialed is 1, pulse once.
  28. digitalWrite(out, LOW); // turn the relay OFF
  29. delay(offtimer); // wait for a while
  30. digitalWrite(out, HIGH); // turn the relay ON
  31. delay(ontimer); // wait for a while
  32. break;
  33.  
  34. case 2:
  35. // If the number to be dialed is 2, pulse twice.
  36. for (int repeat = 0; repeat < 2; repeat++) {
  37. digitalWrite(out, LOW); // turn the relay OFF
  38. delay(offtimer); // wait for a while
  39. digitalWrite(out, HIGH); // turn the relay ON
  40. delay(ontimer); // wait for a while
  41. }
  42. break;
  43. case 3:
  44. // If the number to be dialed is 3, pulse thrice.
  45. for (int repeat = 0; repeat < 3; repeat++) {
  46. digitalWrite(out, LOW); // turn the relay OFF
  47. delay(offtimer); // wait for a while
  48. digitalWrite(out, HIGH); // turn the relay ON
  49. delay(ontimer); // wait for a while
  50. }
  51. break;
  52. case 4:
  53. // If the number to be dialed is 4, pulse 4 times.
  54. for (int repeat = 0; repeat < 4; repeat++) {
  55. digitalWrite(out, LOW); // turn the relay OFF
  56. delay(offtimer); // wait for a while
  57. digitalWrite(out, HIGH); // turn the relay ON
  58. delay(ontimer); // wait for a while
  59. }
  60. break;
  61. case 5:
  62. // If the number to be dialed is 5, pulse 5 times.
  63. for (int repeat = 0; repeat < 5; repeat++) {
  64. digitalWrite(out, LOW); // turn the relay OFF
  65. delay(offtimer); // wait for a while
  66. digitalWrite(out, HIGH); // turn the relay ON
  67. delay(ontimer); // wait for a while
  68. }
  69. break;
  70. case 6:
  71. // If the number to be dialed is 6, pulse 6 times.
  72. for (int repeat = 0; repeat < 6; repeat++) {
  73. digitalWrite(out, LOW); // turn the relay OFF
  74. delay(offtimer); // wait for a while
  75. digitalWrite(out, HIGH); // turn the relay ON
  76. delay(ontimer); // wait for a while
  77. }
  78. break;
  79. case 7:
  80. // If the number to be dialed is 7, pulse 7 times.
  81. for (int repeat = 0; repeat < 7; repeat++) {
  82. digitalWrite(out, LOW); // turn the relay OFF
  83. delay(offtimer); // wait for a while
  84. digitalWrite(out, HIGH); // turn the relay ON
  85. delay(ontimer); // wait for a while
  86. }
  87. break;
  88. case 8:
  89. // If the number to be dialed is 8, pulse 8 times.
  90. for (int repeat = 0; repeat < 8; repeat++) {
  91. digitalWrite(out, LOW); // turn the relay OFF
  92. delay(offtimer); // wait for a while
  93. digitalWrite(out, HIGH); // turn the relay ON
  94. delay(ontimer); // wait for a while
  95. }
  96. break;
  97. case 9:
  98. // If the number to be dialed is 9, pulse 9 times.
  99. for (int repeat = 0; repeat < 9; repeat++) {
  100. digitalWrite(out, LOW); // turn the relay OFF
  101. delay(offtimer); // wait for a while
  102. digitalWrite(out, HIGH); // turn the relay ON
  103. delay(ontimer); // wait for a while
  104. }
  105. break;
  106. case 0:
  107. // If the number to be dialed is 0, pulse 10 times.
  108. for (int repeat = 0; repeat < 10; repeat++) {
  109. digitalWrite(out, LOW); // turn the relay OFF
  110. delay(offtimer); // wait for a while
  111. digitalWrite(out, HIGH); // turn the relay ON
  112. delay(ontimer); // wait for a while
  113. }
  114. break;
  115. }
  116. }
  117. }
  118. didthis=1;
  119. digitalWrite(out, HIGH); // turn the relay ON to keep the phone on the line and wait for the other end to ring.
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement