Electrical – Attiny85 crashes when I run a motor through an L293D

arduinoattiny85l293dmotorpower supply

I'm trying to run a motor through an L293D turned on and off by an Attiny85. The Attiny85 has the micronucleus bootloader on it, which is why pin 3 is connected to a pull up resistor.

On the Attiny is a program that toggles PB0 on and off every second. I've attached an LED indicator on it, and while the motor is not connected to 1Y, it runs fine. It also works fine if I put an LED between 1Y and ground. But when I put a small motor between 1Y and ground, LED1 flashes briefly and then the Attiny resets.

Basically, how do I get it to not crash when running a motor through it?

Motor on L293D
I also tried the following, putting the motor directly on the power supply, doing so prevents the Attiny from starting at all.

Motor on power supply
Specs:

  • 5V wall power supply with up to 3000mA output.
  • Motor pulls around 300 mA while active.
  • Also tried powering it through my computer's USB and got the same results.

What I've tried:

  • Replacing C2 with a 1000uF capacitor. That allowed me to plug the motor directly to the power supply with the Attiny85 running.
  • Putting the 1000uF capacitor between 1Y and gnd. No change.

Update 1:

The reason I was using L293D is because I didn't have any viable diodes at hand while testing. The only ones I had were too big to put on my breadboard. Connected it through alligator clips for now, and made the following changes, and that seems to be working quite well for now:

enter image description here

Best Answer

You have no decoupling capacitors.

You need decoupling capacitors because whenever the ICs switch they will try to draw a surge of current. The power supply can't respond fast enough and even if it does, the current surge will produce a voltage drop through the parasitic inductance of the wires and traces. Either scenario will cause a brownout.

The rule of thumb is to place 0.1uF ceramic capacitors across every pair of power pins as close to the IC as possible.