Easiest way to set pwm frequency on a micro?

Hi guys!
I've got an Arduino Micro on which I am running a gardening project for school.

The fan however makes a high pitch sound when using pwm to control it's duty cycle and I'd like to get rid of that, but need help as this is my first Arduino project :slight_smile:

Currently I am using pin 6 for pwm and I'd like to be able to still continue to change duty cycle with analogWrite(6, duty_cycle) as I already do throughout my program, but I also don't want to risk messing with the delay() function in any way.

I saw there was a lot of similar topics but I am just not capable of understanding a processor datasheet and how to approach this...

I did see something like this in another post though

TCCR1A = bit (COM1A1) | bit (WGM11);
TCCR1B = bit (WGM13) | bit (WGM12) | bit (CS10);

that looked easy enough. Is that something that works on pin 6 without messing with delay() function?

Easiest on a Atmeag328 is the:

Which fan.

4-pin computer fans should be PWM-ed with 25kHz (Intel standard).
Plenty of examples for that.
With 2-pin or 3-pin PC fans all bets are off.
Leo..

Fantastic, thank you :slight_smile:
I do want to be able to use the same code on a Micro, an Uno and a Nano too.
Is that possible with this solution?
Looked like both Micro and Uno can use pin 9 and 10 for this, but I don't know about Nano?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.