led_pwm_control
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
led_pwm_control [2017/01/23 17:47] – [Using PWM from the Command Line] walkeradmin | led_pwm_control [2017/02/01 10:34] – walkeradmin | ||
---|---|---|---|
Line 2: | Line 2: | ||
<color # | <color # | ||
\\ | \\ | ||
+ | \\ | ||
+ | {{: | ||
---- | ---- | ||
Turning on LEDs using the GPIO on the Raspberry Pi is pretty simple. You just turn on or off the relevant GPIO pin, and your LED (connected via a 330r resistor) will come on and go off. | Turning on LEDs using the GPIO on the Raspberry Pi is pretty simple. You just turn on or off the relevant GPIO pin, and your LED (connected via a 330r resistor) will come on and go off. | ||
Line 38: | Line 39: | ||
---- | ---- | ||
+ | \\ | ||
+ | For this example I am going to use GPIO12 (or Physical Pin32). | ||
+ | \\ | ||
+ | \\ | ||
+ | The steps to use the GPIO in PWM mode are very simple: | ||
+ | \\ | ||
+ | \\ | ||
+ | * Setup the Pin as an Output | ||
+ | * Setup the Pin in PWM Mode | ||
+ | * Start the PWM | ||
+ | |||
+ | ---- | ||
+ | ==== Setup the GPIO Pin as an Output ==== | ||
+ | \\ | ||
+ | For this we need to just type in the following line: | ||
+ | \\ | ||
+ | gpio -g mode 12 out | ||
+ | \\ | ||
+ | This sets the mode to Output | ||
+ | \\ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Set the GPIO Pin Mode to PWM === | ||
+ | \\ | ||
+ | gpio -g mode 12 pwm | ||
+ | \\ | ||
+ | This sets the GPIO Pin mode to PWM. | ||
+ | \\ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Set the PWM Frequency ==== | ||
+ | \\ | ||
+ | The PWM frequency is a 10 Bit number, so has a range of 0-1023 | ||
+ | \\ | ||
+ | gpio -g pwm 12 50 | ||
+ | \\ | ||
+ | The Higher the number, the brighter the LED. Simple. | ||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | ---- | ||
+ | ==== LED States ==== | ||
+ | \\ | ||
+ | {{: | ||
\\ | \\ | ||
\\ | \\ | ||
+ | ---------PWM-001------------PWM-010------------PWM-050------------PWM-0100--------------PWM-250--------------PWM-500--------------PWM-999-------- |
led_pwm_control.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1