How is analogWrite() different from digitalWrite()?
DigitalWrite will set the specified pin to two states, either High or Low. This equates the flow of current to be 5V or 0V. AnalogWrite() method sets the value of a PWM output pin and varies on a scale of 0 – 255.