Hy @ All
Just took my first adventure with Arduino. Attached L293d v4 Shield and uploaded a 4 Motor Test sketch found by google assuming it fits my needs:
//#include <Servo.h>
#include <AFMotor_R4.h>
// Common pin definitions for L293D shields
//int EN1 = 6; // PWM for Motor 1
//int IN1 = 7; // Direction for Motor 1
//int IN2 = 4; // Direction for Motor 2
//int EN2 = 5; // PWM for Motor 2
//int EN3
// Erstelle 4 DC Motor Objekte an den Anschlüssen M1, M2, M3, M4
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
// Motoren auf Geschwindigkeit 0 setzen (aus)
void setup() {
motor1.setSpeed(0);
motor1.run(RELEASE);
motor2.setSpeed(0);
motor2.run(RELEASE);
motor3.setSpeed(0);
motor3.run(RELEASE);
motor4.setSpeed(0);
motor4.run(RELEASE);
delay(1000);
}
// Alle Motoren vorwärts
// Geschwindigkeit 0-255 delay(2000);
// Alle Motoren stoppen
void loop() {
motor1.stopMotors(0);
Motor2.stopMotors(0);
Motor3.stopMotors(0);
Motor4.StopMotors(0)
delay(1000);
// Alle Motoren rückwärts
moveBackward(200);
delay(2000);
stopMotors();
delay(1000);
}
// Hilfsfunktion: Vorwärts
void {
moveForward(int speed)
motor1.setSpeed(speed);
motor1.run(FORWARD);
motor2.setSpeed(speed);
motor2.run(FORWARD);
motor3.setSpeed(speed);
motor3.run(FORWARD);
motor4.setSpeed(speed);
motor4.run(FORWARD); }
// Hilfsfunktion: Rückwärts
void {
moveBackward(int speed)
motor1.setSpeed(speed);
motor1.run(BACKWARD);
motor2.setSpeed(speed);
motor2.run(BACKWARD);
motor3.setSpeed(speed);
motor3.run(BACKWARD);
motor4.setSpeed(speed);
motor4.run(BACKWARD);
}
// Hilfsfunktion: Stopp
void {
stopMotors()
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);
}
Starting from scratch there was no error in testing and uploading the sketch. The jumper for external power is removed. It´s a small drill accu with 14.4 Volts. As found in the specs for L293d shield current is supported up t16 Volts. The four DC Motors are 12 Volts for standard Blowers When the Arduino boots all Motors spin in different directions.
If I switch off the Accu-Pack the Motors spin at 5 Volts Arduino current.
I did a lot of searching for reasons the Test-Sketch doesn´t work. Servo.h is outdated and not longer maintained. AF-Motor_R4.h may be the wrong library. But most of other examples on the net are outdated and libraries i found missing the .h or the .cpp file expect in lower directories in the .zip files. Or they simply not fit my hardware. Maybe there is a resistor missing to force all motors to low at the beginning and the reset switches are without results.
I assume the code is not fitting the criteria simply to turn and stop the motors as expected. ;-(
For now i am rather clueless and begging for help to get the neccessary help to achieve a little success.
At least my english fits the criteria of this forum and the thread and post is not a reason for additional comments.
Thks in advance Ede





