(+44) 0793 404 8 777 iwanta@slick.productions

Introduction

So, this one is going to be a long post. I came across this UK telephone number +44 11 7325 7425 (Yes this is a UK number, just a weird area code, honest) (see article here) that when you ring it, rick rolls you down the phone. I loved this idea, and having had a look at the authors’ GitHub, it appears the entire thing is software based. This is of course the most sensible choice as it avoids any hardware and can be replicated relatively straight forwardly. But as a hardware guy, I wanted to see if it was possible to do this in the hardware domain. And this is how this project started.

 

 

Gay Bar?

This end of the project has a slightly convoluted reason for being. Firstly, if I was going to do this, I would need a real-life phone line. At the time I started this project I was a student at the University of Brighton and would have ended up with a landline starting in 01273, which for anyone who knows is the Brighton area code. It then occurred to me, what audio would I use? Brighton has some pretty kick ass gay bars, so I thought Electric Six’s Gay Bar would be an excellent choice. I think this idea might have come to me while I was in Bar Revenge of all places. It loops nicely too, which is important for when it ends up on the answering machine.

Of course, it’s just a tape, I can always choose something else for a different theme.

 

 

Offended?

If the association of “Brighton” and “Gay Bar” offends you, then you have my apologies. This is just a concept, at this stage. Chances are this project might change shape many times before it’s finally finished.

 

 

What do telephone waveforms look like?

Before getting ahead of myself, I was curious to see exactly what PSTN (Public System Telephone Network) waveforms look like. See the pretty pictures for yourself. I may have gotten the polarity incorrect, but I think at this point it’s slightly irrelevant. Resting voltage on the line is -50V DC, ringing is +50V DC, each ringing pulse is 150V pk-pk. Each pulse is 400ms in length, 200ms pause between each pulse, 2 seconds between each pair of pulses. I don’t know about you but i wouldn’t fancy touching the wires, especially when it’s ringing.

Now, it would be simple enough to design some interface to interface to a Arduino using some basic analogue electronics, but I feel, for the moment, I think the easiest way is to “piggyback” off the telephone electronics.

 

 

Methodology

My loose plan for this project was as follows;

> Get corded telephone.

> Get cassette tape player.

> Interface telephone microphone into output from cassette player.

> Interface telephone “ring” to an Arduino Uno.

> Do some logic with an Arduino Uno to control it all and get it to do cool things.

Solve each of these problems, combine and done. Well, almost. Each of the above pointers will have a section to itself.

 

 

Get corded telephone

This proved to be quite the task in Summer 2018, I knew I could probably get one off eBay, but I knew i could probably get one cheaper in person and besides, i wanted to see what i’d be working with. I spent about a month looking for one at Essex boot sales. It was surprisingly hard to find a decently priced simple enough telephone. I eventually found a cheap hideous creme coloured rotary style telephone – but made from cheap plastic. It was dismantled, and its construction was relatively straight forward and easy to interface with. One interesting part was that the phone, even though it was cheap, had a solenoid driven bell inside. I initially thought this would be easy to interface with, but it was more difficult than I imagined, as you’ll see later.

 

 

Get cassette tape player

This too proved to be difficult. I already had a Sony TCM-939, but I was hesitant to pull it apart, and I wanted to keep it. After all, I’m going to need something to record tapes which I can then put in the Answering Machine once it’s done. Early attempts to control the player were done by using servos to hit the play, rewind and stop buttons, although this proved to be a dead end. There are easier ways to do things.

The aforementioned development dead end. Apologies for potato quality photograph. 

An alternative solution was found in a Sony TC-TX333, this was an ideal choice as it has ‘soft buttons’ in the sense that the player mechanics are controlled from push buttons on the front panel. This is then easy to interface either using relays or the easiest option is to use opto-isolators, the TC-TX333 makes this extra easy as all the buttons on the front panel are essentially a resistive ladder.

This ‘bad boy’ came in surprisingly cheap at only  £20 delivered. 

Below is a screenshot of the circuit layout of the font panel push buttons, i couldn’t have asked for a simpler system to graft an Arduino onto.

You can find the full schematic here – TC-TX333 SERVICE MANUAL – hfe_sony_tc-tx333_service_en.pdfSony have some really nice service manuals.

 

Interface telephone microphone into output from cassette player

This was one part of the project that gave me a lot to think about. how do interface a line level signal to a passive microphone? The answer came eventually in the form of an audio isolation transformer and a 10K variable resistor. This solution worked well and provided some volume control which would have been another issue to solve later. I didn’t attempt to match the impedances, I just plugged and prayed, and it worked.

 

 

Interface telephone “ring” to an Arduino Uno

This part was troubling. My initial idea had been to drive a relay using the bell solenoid output, but this output didn’t provide enough current. Using this relay would have been a convenient solution. The end solution was to connect a LED to the telephone ringing outputs, attach an LDR to the LED and then connect the LDR to an analogue input on the Arduino, and use something like “if (sensorValue > 600)” in the code.

 

 

Controlling the Telephone

This section is about how the Arduino interfaces with the PSTN, etc. There are two main relays, a relay that cuts the telephone line off and a relay that deals with the off/on hook switch. Both are DPDT relays, which themselves are controlled from the relay module. This is of course an inelegant solution, something to be improved in the next iteration. The relay in the telephone line may not necessarily be needed, but currently it is used to reset the telephone line after a call.

 

 

Arduino Uno Logic Magic

This was the trickiest part – connecting all the dots up. On the outputs side, we have a 4 Channel 5V Relay Module (Player Play Button, Player Stop Button, Telephone Hang Up switch and line switch) and on the inputs side – we have an LDR on analogue input A0. There is also a I2C 4-line LCD panel, connected via A4 and A5.

The code for this project is attached, I am by no means a coder so there’s many ways this could have been improved.

// Charles Hoile

// Gay Bar Version 1.2

// Automated Telephone Machine for 01273 Numbers

// Some code inspired from here https://www.instructables.com/id/Auotmatic-Street-lights-control-using-LDR-and-Ardu/

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

// 3 = in3 = line cutoff

// 2 = in4 = hook cutoff

// 4 = in2 = stop button

// 5 = in1 = play button

#include <SoftwareSerial.h>

int sensorPin = A0; // select the input pin for the LDR

int sensorValue = 0; // variable to store the value coming from the sensor

void setup() {

Serial.begin(9600);

lcd.begin(20,4);

lcd.setCursor(0,0);

lcd.print(“- The Gay Bar Line -“);

// delay(2000); dont need that shit here

lcd.setCursor(0,1);

lcd.print(“- Version 1.2 -“);

//delay(200);

lcd.setCursor(0,1);

lcd.print(“”);

//delay(200);

lcd.setCursor(0,2);

lcd.print(“”);

//delay(200);

lcd.setCursor(0,3);

lcd.print(“”);

//delay(200);

pinMode(2, OUTPUT);

pinMode(3, OUTPUT);

pinMode(4, OUTPUT);

pinMode(5, OUTPUT);

digitalWrite(2, HIGH); // turns shit off

digitalWrite(3, HIGH); // turns shit off

digitalWrite(4, HIGH); // turns shit off

digitalWrite(5, HIGH); // turns shit off

int sensorPin = A0; // select the input pin for the LDR

int sensorValue = 0; // variable to store the value coming from the sensor

sensorValue = analogRead(sensorPin);

}

void loop() {

// delay(1000);

digitalWrite(3, LOW); // connect phone to line

// wait now for phone to ring

sensorValue = analogRead(sensorPin); // read LDR

Serial.println(sensorValue);

if (sensorValue > 600)

{

digitalWrite(2, LOW); // pick up telephone line

Serial.println(“pick up telephone line”);

playTape();

Serial.println(“play tape”);

countdown38seconds();

Serial.println(“countdown”);

stopTape();

Serial.println(“stop tape”);

digitalWrite(2, HIGH); // drop telephone

Serial.println(“drop telephone”);

delay(50);

digitalWrite(3, HIGH); // drop telephone linepick up telephone line

Serial.println(“Cut telephone”);

}

// else if sensor value isn’t 600 or more, just wait and loop back

Serial.println(“no calls”);

}

//————————————————————————————–

void playTape()

{

digitalWrite(5, LOW); // turn on (press play button)

lcd.setCursor(0,3);

lcd.print(“——–PLAY TAPE–>”);

delay(500); // wait for a second

digitalWrite(5, HIGH); // turn off (release play button) }

void stopTape()

{

digitalWrite(4, LOW); // turn on (press stop button)

lcd.setCursor(0,3);

lcd.print(“——–STOP TAPE–>”);

delay(500); // wait for a second

digitalWrite(4, HIGH); // turn off (release stop button)

//delay(5000);

}

void countdown38seconds() // may the coding gods forgive me for my simpleness

{ lcd.setCursor(0,2); lcd.print(“38”); delay(1000);

lcd.setCursor(0,2); lcd.print(“37”); delay(1000);

lcd.setCursor(0,2); lcd.print(“36”); delay(1000);

lcd.setCursor(0,2); lcd.print(“35”); delay(1000);

lcd.setCursor(0,2); lcd.print(“34”); delay(1000);

lcd.setCursor(0,2); lcd.print(“33”); delay(1000);

lcd.setCursor(0,2); lcd.print(“32”); delay(1000);

lcd.setCursor(0,2); lcd.print(“31”); delay(1000);

lcd.setCursor(0,2); lcd.print(“30”); delay(1000);

lcd.setCursor(0,2); lcd.print(“29”); delay(1000);

lcd.setCursor(0,2); lcd.print(“28”); delay(1000);

lcd.setCursor(0,2); lcd.print(“27”); delay(1000);

lcd.setCursor(0,2); lcd.print(“26”); delay(1000);

lcd.setCursor(0,2); lcd.print(“25”); delay(1000);

lcd.setCursor(0,2); lcd.print(“24”); delay(1000);

lcd.setCursor(0,2); lcd.print(“23”); delay(1000);

lcd.setCursor(0,2); lcd.print(“22”); delay(1000);

lcd.setCursor(0,2); lcd.print(“21”); delay(1000);

lcd.setCursor(0,2); lcd.print(“20”); delay(1000);

lcd.setCursor(0,2); lcd.print(“19”); delay(1000);

lcd.setCursor(0,2); lcd.print(“18”); delay(1000);

lcd.setCursor(0,2); lcd.print(“17”); delay(1000);

lcd.setCursor(0,2); lcd.print(“16”); delay(1000);

lcd.setCursor(0,2); lcd.print(“15”); delay(1000);

lcd.setCursor(0,2); lcd.print(“14”); delay(1000);

lcd.setCursor(0,2); lcd.print(“13”); delay(1000);

lcd.setCursor(0,2); lcd.print(“12”); delay(1000);

lcd.setCursor(0,2); lcd.print(“11”); delay(1000);

lcd.setCursor(0,2); lcd.print(“10”); delay(1000);

lcd.setCursor(0,2); lcd.print(“9 “); delay(1000);

lcd.setCursor(0,2); lcd.print(“8 “); delay(1000);

lcd.setCursor(0,2); lcd.print(“7 “); delay(1000);

lcd.setCursor(0,2); lcd.print(“6 “); delay(1000);

lcd.setCursor(0,2); lcd.print(“5 “); delay(1000);

lcd.setCursor(0,2); lcd.print(“4 “); delay(1000);

lcd.setCursor(0,2); lcd.print(“3 “); delay(1000);

lcd.setCursor(0,2); lcd.print(“2 “); delay(1000);

lcd.setCursor(0,2); lcd.print(“1 “); delay(1000);

lcd.setCursor(0,2); lcd.print(” “); delay(1000); }

 

Wiring Diagram

 

Next Steps

> A nice custom PCB would be nice, to tidy up the design, as it’s currently a mess. This would combine the audio transformer, relays, ATmega328P, 5V regulator and possibly power supply on to a single board.

> The Sony is mains powered, and it’d be nice to have it all run on 12V for simplicity. The Sony is also very energy inefficient, gets nice and toasty, and could possibly serve as a panini sandwich heater in the near future.

> More debug / useful content on the I2C 4 line screen, otherwise what was the point in using it? So much screen real estate.

> It has occurred to me that there is no way of seeing who has called the telephone. Maybe a serial printer of some kind might be a good addition.