Go Down

Topic: PWM on Pin 6 and 13 with Arduino Micro (Read 5064 times) previous topic - next topic

plueb

Hi there,

In my project I want to control a fan and some LED's with PWM. I have 3 LED's on PWM 9,10,11 and they work (can set different brightness levels with analogWrite). I tried to do the same with Pin 6 for the fan. There it doesn't work. It seems as if it can only switch between full and nothing... Looks the same if i use digitalWrite instead of analogWrite.
I connected a LED to Pin 6 and it doesn't work too. If I measure the voltage, it's always on ~5V. If I measure it on 9/10/11 it very with my analogeWrite Value between 0 and 5V...
When I tried it with Pin 13 it was the same.

Could the PWM on Pin 6 and 13 be disabled? How did I do that? I tried to increase the frequency of the PWM so that the fan doesn't make noise. Maybe I had a wrong code there? Is it possible to factory reset all Timers on my Micro? Or how could I enable them again?
Any other ideas what could cause the problem?

Thanks for your help!

Grumpy_Mike

Pin 13 can not produce PWM. Pin 6 can. You can not permenantly disable pin 6 so there is no factory reset possible.
You can disable the pin by using certain libaries that want to use the same timer.

plueb

Hey Mike thanks for your answer. Are you sure about no PWM on Pin 13? On the arduino page it says:

PWM: 3, 5, 6, 9, 10, 11 and 13. Provide 8-bit PWM output with the analogWrite() function.
https://www.arduino.cc/en/Main/arduinoBoardMicro

In my program I'm only using IRemote.h library.
But I experimented a bit with the timers:
TCCR0B = TCCR0B & 0b11111000 | 0x03;

I'm not sure what I entered there exactly, but tried every timer from 1 to 4 ;)
Are this settings saved on the arduino somehow? So that if i remove it from the program, it still would be there?

Any other ideas which could cause the problem with pin 6 (and maybe 13)?

Grumpy_Mike

You look at the board and you will see a little ~ symbol next to the PWM pin. There are only 6 PWM pins on a UNO. Pin 13 is not one of them.

Yes the IR libiary would stop two of those pins working.

Once the power is removed then these pins will go back to the default value. Try your tests without that libiary.

plueb

Yeah but I'm not using an UNO. I have a micro and it definitly says Pin 13 has PWM :)

Ah ok, I didnt' know that :) thank you!

Grumpy_Mike

You should have said you has a micro at the start of your thread. The default Arduino is the Uno, unless otherwise said.

The micro has a 16U4-32u4 processor in it which has different timers to the normal Uno processor therefore a lot of libraries that use timers written for the Uno will not work or will do screwy things when you try and use them with the micro.

Therefore stuff for changing the PWM frequency written for a Uno is unlikely to work with a micro.

Paul__B

You should have said you has a micro at the start of your thread. The default Arduino is the UNO, unless otherwise said.
Don't suppose you happened to read the title of the thread? :smiley-roll:

Grumpy_Mike

Don't suppose you happened to read the title of the thread? 

:smiley-roll: ah no - titles on this forum are not always worth reading though.

Go Up