PWM (Pulse Width Modulation)
Here is one more a little Project of PWM using Arduino and pot-meter. In this Project we are creating PWM according to Pot-meter variation. when voltage increase then decrease duty cycle and if voltage decrease then increase duty cycle and when in middle then 50 % duty cycle.
Same article On: PWM using PIC Microcontroller
Here we are sharing Circuit and Code of Arduino
Required Components
- Arduino Uno
- Resistor 150 ohm
- Pot-meter
- LED
- Connecting wires
Circuit diagram:
Arduino Code:
int potPin = 0;
int pinpwm = 12;
int potval = 0;
int t1pwm = 0;
void setup() {
// put your setup code here, to run once:
pinMode (pinpwm, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
potval = analogRead(potPin);
t1pwm = 1024-potval;
digitalWrite (pinpwm, HIGH);
delay(t1pwm);
digitalWrite (pinpwm, LOW);
delay(potval);
}
No comments:
Write commentsI am very thankful for your precious time