48
Lesson 4 Breathing LED
Introduction
In this lesson, we will try something interesting – gradually increase and decrease the
luminance of an LED with PWM, just like breathing. So we give it a magical name - Breathing
LED.
Components
- 1 * Raspberry Pi
- 1 * Breadboard
- 1 * LED
- 1 * Resistor (220Ω)
- Jumper wires
- 1 * T-Extension Board
- 1 * 40-Pin Cable
Principle
PWM
Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means.
Digital control is used to create a square wave, a signal switched between on and off. This
on-off pattern can simulate voltages in between full on (3.3 Volts) and off (0 Volts) by
changing the portion of the time the signal spends on versus the time that the signal spends
off. The duration of "on time" is called pulse width. To get varying analog values, you change,
or modulate, that width. If you repeat this on-off pattern fast enough with some device, an
LED for example, the result would be like this: the signal is a steady voltage between 0 and
3.3v controlling the brightness of the LED.
Duty Cycle
A duty cycle is the percentage of one period in which a signal is active. A period is the time
it takes for a signal to complete an on-and-off cycle. As a formula, a duty cycle may be
expressed as:
Where is the duty cycle, is the time the signal is active, and is the total period of the
signal. Thus, a 60% duty cycle means the signal is on 60% of the time but off 40% of the time.
The "on time" for a 60% duty cycle could be a fraction of a second, a day, or even a week,
depending on the length of the period.
Содержание Super Kit 3.0
Страница 7: ...4 22 RGB LED 1 23 LED red 8 24 LED white 4 25 LED green 4 26 LED yellow 4 27 NPN Transistor S8050 2 ...
Страница 30: ...27 Also we have drawn a table of the corresponding BCM wiringPi and Name of each pins ...
Страница 78: ...75 Now pull the slide and you can see the two LEDs light up alternately ...