Maker Pro
Maker Pro

Help get our Xmas Tree Blinking Morse Code

My son and I have built a little project with an Arduino, Snap Circuits, and the Christmas tree. I'm good on the programming side but my basic electronics is elementary and rusty.

The Arduino side was easy: we set it up so the unit loops a process which blinks an LED. In order to isolate the delicate circuitry of the Arduino, we hit on using the photosensitive switch in the snap circuits kit. In order to isolate the delicate 6 volt circuitry of the Snap Circuits from the 24 volt DC christmas tree light circuit, we chose to use the photosensitive switch to fire a relay.

This is the circuit:

circuit.png


By placing the signal source LED from the Ardunino into the photosensitive switch, we get a perfect firing of the circuit when the red test LED is in place. However, if I short over the LED (circuit doesn't have enough juice to fire the LED AND switch the relay) I get a very intermitten performance from the relay. It fires, then ignores an on/off cycle, then fires.... (I should say that unlike in the picture, the xmas lights are connected to the Normally Off position on the relay.)

So as a transmitter of morse code, it has a speech impediment. The test LED has a perfect fist, and copies the pattern precisely.

Am I getting interference in the circuit from the stray voltages associated with the relay firing, and feeding back into the transistor? If so, how might I filter the circuit to get a perfect replication of the source LED.
 

Harald Kapp

Moderator
Moderator
Your circuit is far from ideal for controlling the relay by the transistor. Try this circuit:
attachment.php

Make R2 10kOhm or similar, whatever is available. It serves to shut down the transistor completely if no light falls onto the photosensor.
The protective diode may already be includes in the kit's relay element. If not use any standard diode (e.g. 1N4148) that is in your kit. Observe the polarity. The diode is backwards to protect the transistor from the kickbakc-voltage when the relay is turned off.

The problem with your circuit is mainly that the photosensor is connected to the collector of the transistor, but as the transistor switches on, the collector voltage drops, shutting the transistor off again. By connecting the photosensor directly to the positive supply, this cannot happen.
 

Attachments

  • relay.gif
    relay.gif
    20.8 KB · Views: 470
Thank you! Works a treat. Here's the circuit we built following your schematic. We used a 5.2K Ohm resister here in the picture, but I swapped that up for an 100K Ohm on the theory that the only role for this resister is to impede what would otherwise be a short circuit when the photosensor opens the path, and the higher the resistance the longer the batteries will last? Hope I'm not being noob stupid here, it works fine.

morse-xmas-tree-project.png


We had to go back and reprogram the Arduino in order to keep the Xmas tree lights connected to the Normally On side of the relay. We don't run the morse blinker all the time to save batteries, and we wanted the normal state of the lights to be on. But this meant inverting the signal carried by the Arduino LED, which we did programatically by setting the LED voltage LOW instead of HIGH for the duration of the Dot (200 milliseconds) and Dash (600 milliseconds) signals.

Thanks for debugging our circuit, our Xmas tree is now very -- . .-. .-. -.-- !
 
Top