Go Down

Topic: PWM fade 3 leds on Attiny85 (Read 378 times) previous topic - next topic

asuryan

Hi there!

I have an ATTiny85 project where I want to fade 3 LED channels. Unfortunately the ATTiny supports only PWM on PB0 and PB1 out of the box.

I read somewhere that it is possible to get PB4 to PWM too with some wizardery but I do not find any ressources to do so.

Any hints to get PWM on PB4 on an ATTiny85?

Thanks in advance!
Visit my blog! http://electronics.scriblab.de

TheMemberFormerlyKnownAsAWOL


asuryan

The SoftPWM library is not supported on the ATTiny it seems.
Visit my blog! http://electronics.scriblab.de

TheMemberFormerlyKnownAsAWOL

I wasn't suggesting using a library.

Paul__B

As always, you have failed to explain your project in its entirety.

How easy it is to perform software PWM depends critically on what other things you propose to do at the same time.  As AWOL points out, not everything is done with a library and libraries frequently do not suit.

asuryan

#5
Sep 01, 2019, 01:00 am Last Edit: Sep 01, 2019, 01:04 am by asuryan
I see.

The project is very simple:
Fade 3 leds connected to an ATTiny85; a plus would be to offset the fading a little bit so its not that robotic. Nothing more.

So to implement software PWM by myself I just toggle a pin high / low for a few microseconds in a specific frequency I suspect?!

Thanks!
Visit my blog! http://electronics.scriblab.de

Paul__B

A little bit more involved.

Get back to you later on this.  :smiley-lol:

Grumpy_Mike

Quote
So to implement software PWM by myself I just toggle a pin high / low for a few microseconds in a specific frequency I suspect?!
To make PWM change the brightness you have to change the ratio between the on and off time.

PaulRB

#8
Sep 01, 2019, 10:40 am Last Edit: Sep 01, 2019, 11:14 am by PaulRB
Arduino does not support attiny85 "out of the box". You have to install a "core" to enable that. For attiny85 there is a choice of cores and some are better than others.

Many older Arduino tutorials use David A Mellis' core, which only supports pwm on two pins.

Spence Konde's (aka Drazzy, forum member) tiny core supports pwm on 3 pins (PB0, PB1, PB4)for tiny85.

As well as checking if a core has the features you need, another way to decide between cores is to check if it is still actively supported by the author, using the date that the last "commit" (code update) was made on GitHub.

For example:
Quote
Latest commit by damellis about 3 years ago
compared with:
Quote
Latest commit by SpenceKonde 6 days ago

asuryan

Thank you very much.
I have the Mellis core installed and PB4 didnt respond to analogWrite() how it is expected.

I will try the SpenceKondes core and see how things are going.

Thank you very much for your help!
Visit my blog! http://electronics.scriblab.de

Go Up