I am making a simple voltage regulator. The whole idea is to just use ADC to read voltage on output side and based on the result, adjust PWM power. I am using PWM on physical pin 5. That's the same pin as the one connected to Arduino pin 10 on this image below:

image description

This means that if I try to flash the program, ATTiny will start to put PWM power into my Arduino. I don't want that to happen. How can I flash the program safely? Can I do something to prevent it from starting?


This means that if I try to flash the program, ATTiny will start to put PWM power into my Arduino. I don't want that to happen.

Why do you think that is a problem? The "PWM power" cannot be any higher than the supply voltage, and that is 5V. The Arduino has no problem with you providing a 5V PWM signal to an input pin.

The only time it could be a problem is if the pin you are sending the PWM to is set to an output, in which case you could risk overloading the pin. To get around that you just need to insert a small resistor between the ATTiny's pin and the Arduino's pin. 330Ω or so should do it. Just enough to limit the current to a safe value (< 20mA) but small enough that it won't interfere with the programming communication.

A well design schematic for an Arduino ICSP programmer would have had these resistors in all the data communication lines anyway.

  • I used 2KΩ since that's the smallest I found and it worked. I'll probably add resistors to the other lines too. Dec 12 '16 at 10:59
  • I think the Arduino uses 1KΩ between the USB and main MCUs for this same reason. For low(ish) frequencies the resistance isn't that critical. Higher frequencies though can be corrupted by too high a resistance since it acts as a low-pass filter with the gate capacitance of the input pin. 2KΩ should be perfectly fine for the low speeds of ICSP programming.
    – Majenko
    Dec 12 '16 at 11:48

That isn't a problem but if you really want to prevent ATtiny generating the PWM signal right after flashing the firmware, then you might add a jumper to some free µC input and put the while loop at the beginning of the program which reads that input and waits until you remove the jumper. For example, you could enable internall pull-up on some free input and put the jumper from that pin to GND. Then in the code you can just wait for the input to become high and then proceed with the rest of the code. Then you can just insert the jumper, flash the firmware, remove the connections between ATtiny and Arduino and then remove the jumper.


The Arduino-as-ISP sketch will turn all the OUTPUT pins, connected to the ATTiny, back to INPUT. That way nothing bad can happen, when the ATTiny drives those pins HIGH of LOW.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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