Devices & Components
Arduino Nano
10k Ohm 0.5 Watt Metal Film Resistors
Arduino Compatible DC Voltage Regulator
220 Ohm 0.5 Watt Metal Film Resistors
12.6V CT, 7VA 500mA Centre Tapped - Type 2853 Transformer
12V DC 400mA Ultra-Slim Power Supply
IRLZ33N N channel MOSFET
12 Key Numeric Keypad
PC Boards Vero Type Strip - 95mm x 75mm
100 Ohm 1 Watt Carbon Film Resistors
1N4007 1A 1000V Diode
Jiffy Box - Black - 158 x 95 x 53mm
Hardware & Tools
Soldering iron (generic)
Project description
Code
Arduino Nano Partyline Telephone Ringer
arduino
I have used the KISS principle here and used only very basic instructions. This code can easily be "tidied up" with the use of further functions and arrays.
1/* Partyline telephone ringer 2 This will ring a telephone with various ring cadences 3 which may include the standard UK and US rings as well 4 as a number of partyline rings. 5 The number of different cadences is controlled by 6 push buttons - so the number depends on the number 7 of buttons installed. 8*/ 9 10// set pins for ringing output 11 const int ringPin1 = 2; 12 const int ringPin2 = 3; 13 14// Set pin IDs for rows and columns for buttons 15const int rowA = 4; 16const int rowB = 5; 17const int rowC = 6; 18const int rowD = 7; 19const int colA = 8; 20const int colB = 9; 21const int colC = 10; 22 23// set pin for on-board LED for testing purposes 24const int LED = 13; 25 26// define variable for setting length of short ring 27// long ring and NZ and US rings. 300mS should be about 28// right for the short ring, and a long ring 900mS 29// this number is the number of cycles, so at a frequency 30// 20Hz, and a length of 300mS, there are 6 cycles 31// and at 900mS, 18 cycles. 32// At 20Hz, each cycle is 50mS 33unsigned shortring = 6; 34unsigned longring = 18; 35unsigned shortpause = 200; 36unsigned longpause = 2000; 37unsigned NZring = 8; // NZ ring is 400 mS 38unsigned USring = 40; // US ring is 2000mS 39// define variable for setting frequency of ring 40// e.g. for 20Hz, one cycle is 50mS, half cycle is 25mS 41// this number is the length of one half cycle. 42unsigned frequency = 25; 43// declare variable used in subroutine 44unsigned count = 1; 45 46 47void setup() { 48 49// Serial.begin(9600); 50// Serial.println("Partyline ringer"); 51 52 pinMode(LED, OUTPUT); 53 54 // setup pins for the ringing output 55 pinMode(ringPin1, OUTPUT); 56 pinMode(ringPin2, OUTPUT); 57 58 // setup the pins for the buttons 59 pinMode(rowA, OUTPUT); 60 pinMode(rowB, OUTPUT); 61 pinMode(rowC, OUTPUT); 62 pinMode(rowD, OUTPUT); 63 pinMode(colA, INPUT_PULLUP); 64 pinMode(colB, INPUT_PULLUP); 65 pinMode(colC, INPUT_PULLUP); 66 67 //Set all output pins to LOW 68 digitalWrite(ringPin1, LOW); 69 digitalWrite(ringPin2, LOW); 70 digitalWrite(rowA, HIGH); 71 digitalWrite(rowB, HIGH); 72 digitalWrite(rowC, HIGH); 73 digitalWrite(rowD, HIGH); 74 75 digitalWrite(LED, LOW); // set LED to off 76} 77 78void loop() { 79 80 digitalWrite(rowA, LOW); 81 82 // rowA, colA for A (.-) ring 83 if (digitalRead(colA) == LOW) { 84 Ringing(shortring); 85 delay(shortpause); 86 Ringing(longring); 87 delay(longpause); 88 } 89 90 // rowA colB for D (-..) ring 91 if (digitalRead(colB) == LOW) { 92 Ringing(longring); 93 delay(shortpause); 94 Ringing(shortring); 95 delay(shortpause); 96 Ringing(shortring); 97 delay(longpause); 98 } 99 100 // rowA colC for J (.---) ring 101 if (digitalRead(colC) == LOW) { 102 Ringing(shortring); 103 delay(shortpause); 104 Ringing(longring); 105 delay(shortpause); 106 Ringing(longring); 107 delay(shortpause); 108 Ringing(longring); 109 delay(longpause); 110 } 111 112 digitalWrite(rowA, HIGH); 113 digitalWrite(rowB, LOW); 114 115 // rowB colA for Partyline K (-.-) ring 116 if (digitalRead(colA) == LOW) { 117 Ringing(longring); 118 delay(shortpause); 119 Ringing(shortring); 120 delay(shortpause); 121 Ringing(longring); 122 delay(longpause); 123 } 124 125 // rowB colB for Partyline M (--) ring 126 if (digitalRead(colB) == LOW) { 127 Ringing(longring); 128 delay(shortpause); 129 Ringing(longring); 130 delay(longpause); 131 } 132 133 // row B colC for R (.-.) ring 134 if (digitalRead(colC) == LOW) { 135 Ringing(shortring); 136 delay(shortpause); 137 Ringing(longring); 138 delay(shortpause); 139 Ringing(shortring); 140 delay(longpause); 141 } 142 143 digitalWrite(rowB, HIGH); 144 digitalWrite(rowC, LOW); 145 146 // row C col A for S (...) ring 147 if (digitalRead(colA) == LOW) { 148 Ringing(shortring); 149 delay(shortpause); 150 Ringing(shortring); 151 delay(shortpause); 152 Ringing(shortring); 153 delay(longpause); 154 } 155 156 // row C col B for U (..-) ring 157 if (digitalRead(colB) == LOW) { 158 Ringing(shortring); 159 delay(shortpause); 160 Ringing(shortring); 161 delay(shortpause); 162 Ringing(longring); 163 delay(longpause); 164 } 165 166 // row C col C for W (.--) ring 167 if (digitalRead(colC) == LOW) { 168 Ringing(shortring); 169 delay(shortpause); 170 Ringing(longring); 171 delay(shortpause); 172 Ringing(longring); 173 delay(longpause); 174 } 175 176 digitalWrite(rowC, HIGH); 177 digitalWrite(rowD, LOW); 178 179 // row D col A for US ring 180 if (digitalRead(colA) == LOW) { 181 Ringing(USring); 182 delay(longpause); // Since pause between rings for US is 4000mS, repeat this 183 delay(longpause); 184 } 185 186 // row D col B for X (-..-) ring 187 if (digitalRead(colB) == LOW) { 188 Ringing(longring); 189 delay(shortpause); 190 Ringing(shortring); 191 delay(shortpause); 192 Ringing(shortring); 193 delay(shortpause); 194 Ringing(longring); 195 delay(longpause); 196 } 197 198 // row D col C for NZ ring 199 if (digitalRead(colC) == LOW) { 200 Ringing(NZring); 201 delay(shortpause); 202 Ringing(NZring); 203 delay(longpause); 204 } 205 206 digitalWrite(rowD, HIGH); 207} 208 209void Ringing(int length) { 210 count = 0; 211 while (count < length) { 212 digitalWrite(LED, HIGH); // turn the LED on 213 digitalWrite(ringPin1, LOW); 214 digitalWrite(ringPin2, HIGH); 215 delay(frequency); 216 digitalWrite(LED, LOW); // turn the LED off 217 digitalWrite(ringPin2, LOW); 218 digitalWrite(ringPin1, HIGH); 219 delay(frequency); 220 count++; 221 } 222 digitalWrite(ringPin1, LOW); // ensure both pins are LOW at end of ringing cycle 223// Serial.println("finished ringing"); 224} 225
Downloadable files
Veroboard layout
Be care that the MOSFET tabs don't touch!
Veroboard layout

Circuit diagram
Circuit diagram showing all connections and components.
Circuit diagram

Comments
Only logged in users can leave comments