brg
We will be exploring how we can use PWM with our Green LED. Good news is that the sketch will look very similar including the pin location (we will still use 7).  There will be different commands, but our base functionality should be the same.  

This lesson includes a new concept (PWM) that can adjust the 'brightness' of the LED.   

Manually Adjusting Brightness
Here is the code below!  The main difference between the previous lesson is the use of 'analogWrite' rather than 'digitalWrite'.  'digitalWrite' can only turn on the LED or turn it off.  'analogWrite' allows for different brigthness values using the PWM pin (Refer to https://www.arduino.cc/en/Tutorial/PWM for more information). The analog values range from 0 to 255 (0 = off, 255 = highest setting).  

In the code below, we can mimic the previous lesson by using values of 255 and 0 (Lines 19 and 21, respectively). Take some time to try different values and see what happens.  Lower values will make the LED look dimmer compared to higher values.   

2016-11-10_1-26-58.png   
Code Syntax
analogWrite(Pin_Number, Analog_Value) - this command allows us to write a specific 'brightness' value from 0 - 255.  0 = LOW and 255 = HIGH.  

Quote 0 0
UA-63837278-7