Hi
I just got a Wifi Arduino car and put in NodeMCU esp8266 …
Controlling it both web page and C# speech say forward it moves forward, but I can not get analogWrite() function to adjust the speed by PWM …
I have read may tutorials. each, when applied failed. Any ideas or different H-Brigde?
Regards
derek
Hi.
As I’ve told you the duty cycle range for the PWM of the ESP8266 is 0 to 1023.
However, when controlling the motor, low duty cycles values may result in a weird buzz sound, and the motor won’t move.
You need to experiment and see what is the lowest value that makes the motor move.
If you experiment higher duty cycles, the motor will probably move.
For example, try:
analogWrite(enA, 990);
Then, let me know the results.
Regards,
Sara
Hi.
I’ve experimented with the L298N driver with an ESP32, and it worked fine to adjust the speed. So, I don’t think the problem is related with the H-bridge.
We have a tutorial about the L298N driver with the ESP32 that may be useful to better understand how the L298N driver works: https://randomnerdtutorials.com/esp32-dc-motor-l298n-motor-driver-control-speed-direction/
Which pins are you using for PWM? Have you tried generating a PWM signal on a separated sketch and see if it is working with that pin?
Also, please note that the PWM analog range of the ESP8266 is 0 to 1023. (while with an Arduino is 0 to 255).
If you provide more details, maybe I can help you better.
Regards,
Sara
Hi
Thank you for responding …
It work with the Arduino, so I put in a ESP8266 for its Wifi
How to Make Arduino ESP8266 WiFi Robot Car
https://youtu.be/2AL7HfiRlp4?t=313
but he does not use analogWrite just set enA to HIGH (255)
Learn about the L289N
Controlling DC Motors with the L298N H Bridge and Arduino
https://youtu.be/dyjo_ggEtVU?t=4
pins for NodeMCU esp8266
https://circuits4you.com/2018/02/20/esp8266-arduino-digital-io/
https://www.youtube.com/watch?v=c0tMGlJVmkw
//Code …
///////////////////////////////////////////////////////////////
//Global variables
// Set speed range 0~255
n = 150; // this comes from webpage or C# WebClient/Speech 5.4
// Motor A
int enA = D2;
int in1 = D3;
int in2 = D4;
// Motor B
int enB = D5;
int in3 = D6;
int in4 = D7;
//example
void forward()
{
// server.send(200, “text/plane”, “forward … “); //Send client ajax request
//Motor A
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
analogWrite(enA, n); // n is set to 150
//Motor B
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
analogWrite(enB, n);
}
It moves forward, back etc … when put in
digitalWrite(enA, HIGH);
digitalWrite(enB, HIGH);
but no speed control for
analogWirites(enA, 150);
analogWirites(enB, 150);
just a hum from the L289N
Maybe its the Pins
Regards
derek
Hi Sara
Thank you Thank You Thank You
I Live and Learn … its works
Keep Smiling
derek