Problem with Attiny85

Hi, I need to control 2 horns with Attiny85 but I have this problem:
I use two IRF540 Mosfet to control the horns because they absorb +2A.
When the sketch start, the Attiny85 doesn’t work but if I replace the horns with two LEDs all works fine.
There aren’t programming issues, i think that problem is the current that horns absorb that disturb the Attiny85

Thanks a lot!

I attach the sketch:

FedeV2.ino (1.24 KB)

You should provide more information.

There aren’t programming issues, i think that problem is the current that horns absorb that disturb the Attiny85

As you believe that the problem is the hardware you should provide information regarding the hardware: schematics, link to the horn an so on.

My crystal ball does not work very well at the moment :slight_smile: but:
Stable power supply (at least for the ATtiny) is essential - do you have 0.1 µF ceramic caps between Vcc and GND (as close as possible to the µC pins)?
The mosfet IRF540 may not be the best choice - it is not a logic level mosfet, it may not work so well with low voltage like 5 V

This is a wiring/electronics problem, post schematic - that’s where the problem is.

Is the power supply you’re using sufficient for a 2A load?