[vc_row][vc_column][vc_column_text]
PWM is short for Pulse Width Modulation. PWM is a method that digital code for the analog signal level. Since the computer can not output the analog voltage, it can only out put 0 or 5V digital voltage value, and we can use the high resolution counters ,use the square wave duty cycle modulated to code for a particular level of the analog signal . PWM signal is still digital, for the full DC supply is either 5V (ON), either 0V (OFF) in any given moment.
Voltage or current source is a kind of ON or OFF repetitive pulse sequence applied to the analog load. ON is the DC power applied to the load, OFF is the DC power disconnected. Sufficient bandwidth, any analog value can be encoded with PWM. The output voltage value is calculated by the time of ON or OFF.Output voltage = (ON time / pulse time) * Maximum voltage value
PWM is used in many places, dimming lights, motor speed, sound production and so on.
Here are some of the PWM three basic parameters:
[/vc_column_text][vc_tour][vc_tab title=”Specific” tab_id=”1394761322-1-41″][vc_column_text]1.The pulse width variation amplitude(min/max)
2.The pulse period(1 second inverse number of the pulse frequency)
3.The voltage height(eg:0V-5V)
Arduino ontroller has six PWM digital interface 3,5,6,9,10,11,before we have done a small lamp button control experiment, it is a digital signal control experiments, we have done potentiometer experiment, this time we have to complete a small lamp potentiometer control experiments.
[/vc_column_text][/vc_tab][vc_tab title=”Components” tab_id=”1394761322-2-11″][vc_column_text]1 * Potentiometer module
1 * Red M5 DIP LED
220Ω line resistance
1 * Bread board
Breadboard Jumpers[/vc_column_text][/vc_tab][vc_tab title=”Wiring Diagram” tab_id=”1394764947935-2-4″][vc_column_text]Potentiometer input analog value is the analog port we received, we received a small lamp PWM
interface, so that by generating different PWM signal can make a small lamp with brightness
different variations.
Let’s follow the diagram to connect the physical map
In the preparation of the program, we will use the simulation write analogWrite (PWM interface,
analog value) function, for the simulation write analogWrite () function, which usage is also very
simple, we read in this experiment potentiometer analog value signal and assigns PWM interface
makes small lights produce a corresponding change in brightness, and then displayed on the
screen read analog value, we can understand the value of this program is to read in a simulated
experimental procedures that will more PWM interface analog value is assigned to this section[/vc_column_text][/vc_tab][vc_tab title=”Test code” tab_id=”1394764948693-3-3″][vc_column_text]
int potpin = 0 ;/ / define analog interface 0 int ledpin = 11 ;/ / define the digital interface 11 (PWM output) int val = 0 ;/ / temporary values of the variables from the sensor void setup () { pinMode (ledpin, OUTPUT) ;/ / define the digital interface 11 as output Serial.begin (9600) ;/ / set the baud rate to 9600 / / NOTE: analog interface is automatically set to the input } void loop () { val = analogRead (potpin) ;/ / read sensor analog values and assigned to val Serial.println (val) ;/ / display val variable analogWrite (ledpin, val / 4) ;/ / turn on the LED and set the brightness (PWM output max 255) delay (10) ;/ / delay of 0.01 seconds }
After downloading the program, we rotate the potentiometer knob only see the change in the value
on the screen can also clearly see our breadboard brightness LED lights also changes.[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]
Leave a Reply
You must be logged in to post a comment.