Skip to content

Commit

Permalink
info
Browse files Browse the repository at this point in the history
  • Loading branch information
ImplFerris committed Oct 20, 2024
1 parent 38080b3 commit 1d32a27
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/blinky/rp-rs.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,26 @@ cd pico2-blinky/rprs-blinky

You refer the ["Running The Program"](../running.md) section

## What is PWM?
PWM stands for **Pulse Width Modulation**. It is a technique used to control the amount of power delivered to a device by adjusting the width of the pulses in a signal.

In PWM, a digital signal switches between **on** and **off** states at a high frequency. The **duty cycle** of the signal determines how long it stays on compared to how long it stays off.

- **Duty Cycle**: The percentage of time the signal is on during one cycle.
- For example:
- 100% duty cycle means the signal is always on.
- 50% duty cycle means the signal is on half the time and off half the time.
- 0% duty cycle means the signal is always off.

In the above example code, we use PWM to fade an LED.

### Fading Up
The first loop gradually increases the LED brightness from `LOW` (0) to `HIGH` (25,000). The `delay.delay_us(8)` creates a short pause between each increase, allowing the LED to visibly brighten.

### Fading Down
The second loop decreases the LED brightness back down to `LOW` (0), again using the same delay to make the transition smooth.

### Pause
After fading up and down, the program pauses for 500 milliseconds before repeating the cycle, allowing the LED to rest briefly.

Play around by adjusting the `delay` and observe. You can even comment out one of the for loop and observe the effect.

0 comments on commit 1d32a27

Please sign in to comment.