Relay problem with AVR ATMEGA168

Discussion in 'Embedded Systems and Microcontrollers' started by ViennaMike, Oct 28, 2008.

  1. ViennaMike

    Thread Starter New Member

    Oct 28, 2008
    I'm trying to control an MP3 player with a microcontroller. The MP3 player has one button for on/off/play/pause, so I've got two leads soldered in to bypass the switch. These are connected to a 5V Radio Shack reed relay, which is controlled by an output pin on the microcontroller. The software works fine. If, instead of the leads from the MP3 Player, I use the relay to control power to an LED, all works exactly as it should. But if I have either the MP3 leads or no load on the relay, the relay is unstable and rapidly cycles on and off.

    I'm looking for quick help on what I'm doing wrong and how to fix it, as I hoped to have this control a talking skull on Halloween.
  2. hgmjr

    Retired Moderator

    Jan 28, 2005
    Can you post a schematic of your circuit so that we can see for ourselves if there are any obvious weaknesses in the design?

    Relays can introduce some significant noise into the design if the proper precautions are not taken. Microcontrollers operate best when their power source is clean. The most likely explanation is that noise on the main power supply is being induced by the energizing of the relay. Another thing to check is that a flyback protection diode is installed across the relay's coil.

  3. amolhshah


    Aug 12, 2008