Arduino Asked by Ameya Savale on February 28, 2021
I am relatively new to adruino and this whole space. I am currently trying to power a DC motor using an ESP12E motor shield and an ESP8266 Module
Motor Shield – https://www.amazon.com/gp/product/B078CPZDW1/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
ESP8266 – https://www.amazon.com/gp/product/B010O1G1ES/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
DC Motor – https://www.amazon.com/gp/product/B07MTT7B88/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
Here is my code
#define DIRA 0
#define PWMA 5
#define LED 2
void setup() {
Serial.begin(9600);
Serial.println();
Serial.println("Starting...");
Serial.println("Preparing motor...");
pinMode(DIRA, OUTPUT);
pinMode(PWMA, OUTPUT);
analogWrite(PWMA,0);
digitalWrite(DIRA,1);
delay(5000);
Serial.println("Starting motor...");
analogWrite(PWMA,5);
delay(5000);
}
void loop() {
}
Here is how I have wired it up
Note: This setup is similar to what I have but not exactly, I have 4 AA batteries connected and only 2 motors
I am expecting the motor to start once I upload this code but nothing is happening. If I change the analogWrite to digitalWrite, the motor runs but I want to be able to control the speed, rather than just having it run at one speed.
I have tested using analogWrite by changing the intensity of an LED and it was working, although the output pin was not the same as the one I use for the motor.
Would greatly appreciate any help as I have already gone through pages of google searches without any luck. I have been using this example as a reference, https://hackaday.io/project/8856-incubator-controller/log/29291-node-mcu-motor-shield.
This answer is the summary of the comments of the question. The idea of the solution was originally mentioned by @Majenko.
You powered the shield with about 6 Volts. The statement analogWrite(PWMA, 5);
gives you (5/1024) ~ 0.5% of this 6 Volts at the output pin PWMA. This 0.03V are not enough to drive the motor.
You should use at least 3 Volts to drive the motor (as of the specs).
This can be achieved by using a duty cycle of the PWM signal of about 50%. analogWrite(PWMA, 512);
should do the trick.
Answered by Peter Paul Kiefer on February 28, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP