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.
analogWrite(PWMA,5);
I would suggestanalogWrite( PWMA, 25 );
.analogWrite(PWMA, 10)
,analogWrite(PWMA, 50)
,analogWrite(PWMA, 100)
but still nothinganalogWrite
is 1023 not 255. You powered the shield with about 6 Volts. To be sure, you should uses at least 3 Volts to drive the motors. Use a duty cycle of 50% `analogWrite(PWMA, 512);. A value of 100 is just 10% (i.e. a mean voltage of about 0.6 Volts.) If this is still not enough, try if the motors run if you connect them to 2 or 3 of your batteries directly. If not, you batteries might be discharged or the motor is defect. If the motor runs with direct connected batteries, the shield might be defect. Have you tried the 2nd motor too?analogWrite
to 512 the motor started spinning. Thank you so much!