CellPhone Operated Toggle Switch

 Light from a mobile phone's display screen could be used to trigger a switch. When a brief (free) phone call illuminates the display - the light from the display operates a 4017 based Toggle Switch. And any small push switch - connected in parallel with the LDR - will provide optional manual control.

The switch can be operated remotely - from any phone. The call should be kept below about 5 seconds. With the phone's backlight set to turn off 10 seconds after the call ends - the screen will go dark after a maximum of about 15 seconds. This is more than long enough to toggle the switch. And - if you know the state of the relay before the call - you'll know its changed state - after the call.


But lets say you don't know - or you've forgotten - the current state of the relay. Then what? The solution is to begin by resetting the circuit. If you extend the length of the call to at least 30 seconds - the 4017 will reset. The state of the relay before the extended call - doesn't matter. After the extended call - it will be de-energized. And the next (short) call will cause it to energize.


This switch will have many uses. And not all of them will involve distance. So I've included a number of signals - to indicate the changing state of the relay. When the relay energizes - the red LED lights - the green LED flashes twice - and the Buzzer gives two short beeps. When the relay de-energizes - the red LED turns off - the green LED flashes four times - and the Buzzer gives four short beeps.


The LEDs and Buzzer are not necessary to the operation of the circuit. You can leave them out if you wish - together with their associated components. That is - you can leave out all of the components - coloured purple in the schematic diagram.

  The Support Material includes a detailed circuit description - a parts list - a step-by-step guide to construction - and more. I used a single pole relay in the prototype - but you can use a mult-ipole relay if it suits your application.
Circuit/ Component summary:
The relay is controlled by pin 2 of the 4017.
Every time pin 14 of the 4017 is taken high -
The pin 2 output changes from low to high - or vice versa.
The first time pin 14 is taken high - pin 2 goes high.
When pin 2 goes high - it's connected internally to the positive line.
And it supplies base current to Q1 - through R1.
The base current switches the transistor on.
The transistor connects the negative side of the relay coil to ground.
And the relay energizes.
The next time pin 14 of the 4017 is taken high - pin 2 goes low again.
When pin 2 goes low - it's connected internally to the negative line.
And it can no longer supply Q1 with base current.
Deprived of its base current - the transistor switches off.
This breaks the relay coil's connection to ground.
And the relay de-energizes.
The 4017 is acting as a toggle switch.
Every time pin 14 is taken high - pin 2 changes state.
If pin 2 is low - it goes high.
And if it's high - it goes low.
When pin 2 goes high - the relay energizes.
And when it goes low again - the relay de-energizes.
For a detailed account of how the 4017 toggle switch works - click on the link below the schematic diagram.
Pin 14 of the 4017 is controlled by pin 3 of the 4001.
The instant light falls on the LDR - pin 3 of the 4001 goes high.
Pin 3 takes pin 14 of the 4017 high
And pin 2 of the 4017 changes state.
Thus - at the beginning of every phone call -
The relay changes state.
If it's de-energized - it will energize.
And if it's energized - it will de-energize.
Pin 3 of the 4001 also does a second job.
While it's high - it supplies the power required to drive the transistor oscillator.
Q2 & Q3 oscillate at a rate of about - one second on - and one second off.
The speed of the oscillation is set by the values of C4 & C5.
The output from the oscillator is at the collector of Q3.
As Q3 switches on and off - it switches Q4 on and off - at the same rate.
When Q4 switches on - it connects the negative side of the buzzer to ground.
And when Q4 switches off - it breaks that connection to ground.
Thus - while pin 3 of the 4001 is high - and the oscillator is running - the buzzer emits a series of one-second beeps.
The beeps tells you that the relay has just changed state.
And the number of those beeps indicates the current state.
If you hear two beeps - you know that the relay has just energized.
And if you hear four beeps - you know that the relay has just de-energized.
The gates of the Cmos 4001 - are divided into two pairs. That is - 1 & 2 and 3 & 4.
Each pair of gates - is wired to form a monostable.
And both monostables are triggered by light falling on the LDR.
For a detailed account of how a monostable works - click on the link below the schematic diagram.
Put simply - when a monostable is triggered - its output pin goes high for a fixed length of time. And - when that time is up - the pin goes low again.
Gates 1 & 2 form the blue monostable.
The instant light strikes the LDR - the blue monostable triggers.
Pin 3 goes high - for a few seconds. And the 4017 toggle switch - changes the state of the relay.
Gates 3 & 4 of the 4001 form the green monostable. Its output is at pin 11. And its job is to reset the Cmos 4017. In other words - it forces the relay to de-energize.
When light strikes the LDR - the green monostable does NOT trigger immediately.
For the green monostable to trigger - the light MUST continues to strike the LDR for at least 30 seconds.
This allows the shorter calls to toggle the relay - without causing a reset.
The 4017 will only reset - when the duration of the call is extended to 30 seconds or more.
That's the length of time it takes for C9 to charge - through the LDR, R14 & R13.
When the voltage across C9 takes pin 8 high - the green monostable will trigger. And the 4017 toggle switch will assume the Off position.
If the light disappears before the 30 second delay had expired -  Any charge in C9 will quickly discharge again - through D5 & R12. And the green monostable's 30-second trigger delay - will reset. When the call lasts for at least 30 seconds -
The green monostable will trigger - And pin 11 will go high for a few seconds.
The high pin 11 - takes pin 15 of the 4017 high - through D4. And the 4017 counter resets to zero.
When the counter resets to zero - pin 3 will go high.
And all of the other outputs - including pin 2 - will go low.
Since pin 2 is low - Q1 is switched off.  And since Q1 is switched off - the relay is de-energized.
In other words - the state of the relay before the extended call - is irrelevant.
After the extended call - when the green monostable has reset the 4017 - The relay will always be left in a de-energized state.

The length of time pin 11 remains high - is not very important. It depends on the values of R16 & C10.
With the current values - the high lasts for about a second or so.
This is more than long enough to reset the 4017 counter.
The length of time the blue monostable's output remains high - is not quite that simple.
This is because pin 3 has two jobs to do. It not only drives the clock input of the 4017
It also provides power for the Q2 & Q3 oscillator.
That is - pin 3 is also responsible for the number of times the green LED flashes - and the buzzer sounds.
When the relay de-energizes - we want pin 3 to remain high for about 7 seconds.
That is - long enough to sound the buzzer four times. On the other hand - when the relay energizes - we want pin 3 to switch off earlier. That is - after only two beeps.
The length of time pin 3 remains high - depends on how long it takes for C7 to charge. When the blue monostable de-energizes the relay - C7 is charged by R15 alone. And this produces the longer (four beep) output - at pin 3.
But when the blue monostable energizes the relay - pin 2 of the 4017 goes high
And C7 receives additional charge - through R2 & D2 This additional current - speeds up the rate at which C7 charges.
And shortens the length of the the pin 3 output - to just two beeps.
Relay coils and some sounders produce large reverse voltage spikes that will destroy Cmos ICs.
D1 & D7 short circuit these spikes at source - before they can do any damage. The remaining diodes all create one-way paths. D2 allows a high pin 2 to charge C7 - but it prevents a low pin 2 from taking pin 1 of the 4001 low. D3 allows a high pin 4 to take the reset pin high - but it prevents a low pin 4 from taking the reset pin low. D4 does the same job - in relation to pin 11 of the 4001. It allows a high pin 11 to take the reset pin high - but it prevents a low pin 11 from taking the reset pin low. D5 allows C9 to discharge quickly through R12 - but it forces C9 to charge slowly through R13. D6 allows Q4 to take pin 1 of the 4001 low - but it prevents Q4 from discharging C7.  And D8 allows Q4 to take pin 1 of the 4001 low - but it prevents R10 from taking pin 1 high. D8 makes sure that the final beep - will always be the same length as all the previous beeps. If pin 3 were to go low - while the buzzer was actually sounding - the oscillator would stop abruptly - And the final beep would be cut short. D8 prevents this from happening.
While the buzzer is sounding - Q4 holds pin 1 low - through D8.
This diverts both the R2 and R15 currents to ground -
And so it pauses the charging of C7 - temporarily. C7 can only complete its charge - after Q4 has switched off.
So the final beep will be the same length as all the other beeps. specified a relay with a minimum coil resistance of 270 ohms. Use a higher value if you wish. With a 12-volt supply - the maximum current through Q1 will be about 45mA. This is well within the limits of the BC547 - which has an IC(max) of 100mA.
There is nothing special about the transistors. So long as the NPN/PNP requirement is satisfied - any small transistors with a gain (hfe) greater than 100 and an IC(max) of at least 100mA - should do. But remember that the pin configuration of your transistors may be different from that of the BC547 and BC557.
Cmos IC inputs are very sensitive.

They will respond to stray electromagnetic interference.
If the circuit is to behave reliably - these stray high frequency signals must be shorted to ground - before they reach the input pins.
To high frequency interference signals - 100nF capacitors represents a short circuit.

C2 shorts the interference to ground before it can reach the clock input pin.
And C8 does the same job for the input pin of the blue monostable.
The timing capacitor - C9 - is protecting the input pin of the green monostable.
And C1 is doing a similar job for the circuit's supply lines.
At power-up - C3 takes the Reset pin of the 4017 momentarily high. This means that the switch will always starts off with the relay de-energized.
If you connect a simple push button switch in parallel with the LDR - You can operate the circuit manually.
The purpose of R14 & C6 is to debounce the push switch contacts.

No comments:

Post a Comment