I have an Arduino Uno R3 with an ATmega238 microchip. I can't upload any code to it: the green led and pin13 LED are always on (without flashing ) and the RX and TX LEDs don't flash when I upload code or press the reset button. Is the microchip malfunctioning?

And what happens when a reverse current returns to Arduino from a relay?

1 Answer 1


You basically have 2 questions here.

1: Why is my Uno not uploading code.

2: How does back EMF effect a microcontroller. We'll address 2 first

When a relay module is activated, it energizes a coil to close a switch. This coil is an inductor, which is an energy storage device. When the signal to the relay tells it to turn off, your trying to de-energize the coil. Whereas before you let current run through the coil to establish a magnetic field, now you cut the current supply and let the magnetic field die out. The problem this creates is back EMF. As Faraday's law will tell us, a change in a magnetic field causes a voltage (an EMF) in a coil. When we were charging the circuit, this was the voltage applied to the coil. When we discharge the inductor, this voltage is back EMF, and is in the opposite direction as charging voltage.

How does this affect your arduino? Well, it can be anything ranging from harmless to catastrophic. It may simply reset your arduino (as one I was working with did on a past project [where an occiliscope showed back EMF spikes in excess of -30V]) or it might straight-up burn the ATMega328p that acts as the Uno's brain. Or it might take out the voltage regulator, or cause a host of other problems.

The simplest fix for back EMF is to put a diode in parallel with the relay with cathode to your positive terminal and anode to your negetive terminal. This creates a short for the relay's coil to discharge through. Some better solutions (especially for sensitive digital equiptment) involve entirely isolating the relay's power supply form the rest of your circuit with an optoisolator.

Problem 1: Assuming that these problems were related to the use of a relay without the proper safeguards, you might try a few things to verify your chip is still alive. If you have a second arduino you might try using it to build an ISP, which will allow you to both reburn the bootloader and upload sketches independently of the uno's onboard usb com port programmer. If that works but the onboard programmer still does not, you may need to reflash the programmer (which I've read can also be done with an ISP, though I've never tried it.)

Hope that helps!

  • Thank very much your answer relay very useful i well try to build an ISP and tell what happened if you have no problem .
    – Hsn.aldeeb
    Commented Jul 4, 2017 at 19:55
  • Sorry but what happened when ISP doesn't work ?
    – Hsn.aldeeb
    Commented Jul 5, 2017 at 5:58
  • If ISP isn't working (double check your ISP hookup circuit because it is easy to mess up--I've done that myself a few times) then its time to look at replacing the ATMega328p chip. If you have one of the boards with DIP chip, this is as simple as pulling out the old one and dropping in a new one. If you have the smd version, you'll have to re solder it. You might also, if you have multimeter handy, probe the different parts of the power system and make sure that that is all working okay before you go thru the hassle of getting a new ATMega328p.
    – user29032
    Commented Jul 5, 2017 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.