Hi everyone,
I need your help!
I'm new to Arduino: here is what I'm trying to do and the description of my problem, plus all relevant info.
I really appreciate any help with debugging.
Thanks
GOAL: Control a 12V dc motor with arduino uno, its motor shield L293D and an external power supply
PROBLEM: Once successfully compiled the sketch, nothing happens. The motor stands still, no sign of life.
HARDWARE in use:
- Arduino Uno R4 WiFi
- L293D Motor Shield
- DC Motor 775 12-36V 3500-9000rpm (I have no data sheet, but motor spec reports the following: DC 12V, Electric Current 0.16A, 3500rpm)
- Power Supply: 12V battery charger (the front reports: 12V, 2.5A arith, Min 25Ah)
WIRING:
- L293D plugged on top of arduino Uno
- Arduino Uno powered via USB-C with Laptop
- Battery Charger connected to L293D Ext_Pwr slot; Jumper removed from the shield (in order to power the motor with the external supply)
- DC motor connected to M1 slot
see image attached
CODE:
I've installed the Adafruit V2 library and compiled the following sketch:
#include <Adafruit_MotorShield.h>
// Definizione dei pin della scheda L293D Shield
#define MOTOR_IN1 4
#define MOTOR_IN2 5
void setup() {
// Impostazione dei pin come output
pinMode(MOTOR_IN1, OUTPUT);
pinMode(MOTOR_IN2, OUTPUT);
}
void loop() {
// Fai girare il motore in avanti
digitalWrite(MOTOR_IN1, HIGH);
digitalWrite(MOTOR_IN2, LOW);
delay(2000); // Aspetta 2 secondi
// Fai fermare il motore
digitalWrite(MOTOR_IN1, LOW);
digitalWrite(MOTOR_IN2, LOW);
delay(1000); // Aspetta 1 secondo
// Fai girare il motore all'indietro
digitalWrite(MOTOR_IN1, LOW);
digitalWrite(MOTOR_IN2, HIGH);
delay(2000); // Aspetta 2 secondi
}
WHAT HAPPENS and Hypothesis:
- If I connect the motor directly to the power supply it works just fine (so the motor works)
- The led on Arduino Uno is light up (when connected to laptop via usb)
- The led on the L293D shield lights up when I connect the external battery
- The sketch compiling is successful (no error)
What could be the reason why the motor is not moving at all? Is it the code, the wiring or the Power Supply insufficient? (perhaps not all 12V get to the motor?)
If you can suggest what check I can to to find the problem, I'll follow up. I have a multimeter but not sure how to use it in this case.
Thanks!
