analogWrite command

I watched a tutorial video on RGB LEDs and they were using Pins 8, 9 & 10 doing analogWrites to each pin to get various colours. I assumed that analog write commands could only be used on PWM pins, of which 8 isn't 1. Have I missed something here?

Puzzled

Which Arduino board was being used ?

Please provide a link to the video

UKHeliBob:
Which Arduino board was being used ?

Please provide a link to the video

It is an arduino UNO (Elegoo) and the video link is https://www.youtube.com/watch?v=kj2br03bOuk&feature=emb_logo

Bad tutorial. Pin 8 is used for the Red LED and when switching from digitalWrite() to analogWrite() he only ever uses 0 and 255 for the red value. Those two are equivalent to digitalWrite(8, LOW) and digitalWrite(8, HIGH). As long as you don't try to get any color with an intermediate amount of red it will appear to work. Any value below 512 will act the same as 0 and any value of 512 or higher will act as 255 (that's how analogWrite() works on non-PWM pins).

He should have moved Red to a PWM pin when switching from digitalWrite() to analogWrite().

Perhaps he should drink less coffee?

I really thought I had missed something! Thanks for the confirmation that my assumption was correct!

fionning_macara:
Perhaps he should drink less coffee?

Who? @ johnwasser? Probably :smiley: