I am new to these Arduino things, and I am currently using an Uno board for my projects.
I don't know how to control the DC motor with the help of digital pins via L293D. But I cannot use the PWM pins of Arduino, since I have already used them for controlling servos and other things, which need higher accuracy.
I tried using the SoftPWM library to control motor, but it is conflicting with other things like ultrasonic sensor. I don't know what the problem is.
Could someone suggest me a solution?
-
This is not an answer, but looking at softPWM library disables regular pwm? might help.Greenonline– Greenonline2016年02月01日 06:30:18 +00:00Commented Feb 1, 2016 at 6:30
1 Answer 1
You can implement PWM using digital pins by turning the pin on and off with respect to your duty cycle, because PWM (Pulse Width Modulation) depends upon the duty cycle the % amount during which the pin is HIGH or LOW
Let say pin 13 of arduino is connected to your l293D enable pin
Sample Code:
void setup() { pinMode(13, OUTPUT); }
void loop() { digitalWrite(13, HIGH); delayMicroseconds(100); // Approximately 10% duty cycle @ 1KHz digitalWrite(13, LOW); delayMicroseconds(1000 - 100); }
Details are also on Arduino Help