i devised a new code that is operational and seems to have solved my problem but does not give me dependable simultaneous operation of both motors but it shall do..... i thank you all for your input on this matter. here is a copy of my redone code
int pinI1=8;//define I1 interface
int pinI2=11;//define I2 interface
int speedpinA=9;//enable motor A
int pinI3=12;//define I3 interface
int pinI4=13;//define I4 interface
int speedpinB=10;//enable motor B
int rcleft=2; //rc reciever inputs which are just basic
int rcright=3; // 5 volt on off buttons so to speak because
int rcforward=4; // my reciever is not pwm
int rcbackward=5;
void setup()
{
pinMode(pinI1,OUTPUT);
pinMode(pinI2,OUTPUT);
pinMode(speedpinA,OUTPUT);
pinMode(pinI3,OUTPUT);
pinMode(pinI4,OUTPUT);
pinMode(speedpinB,OUTPUT);
pinMode(rcleft,INPUT);
pinMode(rcright,INPUT);
pinMode(rcforward,INPUT);
pinMode(rcbackward,INPUT);
}
void forward() //one could use analogWrite to slow the speed of the
{ // motors but if you wanted to adjust the speed
// you would have to reupload the sketch
digitalWrite(speedpinB,HIGH);
digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
digitalWrite(pinI3,LOW);
}
void backward()
{
digitalWrite(speedpinB,HIGH);
digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
digitalWrite(pinI3,HIGH);
}
void left()
{
digitalWrite(speedpinA,HIGH);
digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
digitalWrite(pinI1,LOW);
}
void right()
{
digitalWrite(speedpinA,HIGH);
digitalWrite(pinI2,LOW);//turn DC Motor A move clockwise
digitalWrite(pinI1,HIGH);
}
void stop()
{
digitalWrite(speedpinA,LOW);// Unenble the pin, to stop the motor. this should be done to avid damaging the motor.
digitalWrite(speedpinB,LOW);
digitalWrite(pinI1, LOW);
digitalWrite(pinI2, LOW);
digitalWrite(pinI3, LOW);
digitalWrite(pinI4, LOW);
}
void loop() {
if (digitalRead(rcleft) == HIGH) {
left();
}
else if (digitalRead(rcright) == HIGH) {
right();
}
else if (digitalRead(rcforward) == HIGH) {
forward();
}
else if (digitalRead(rcbackward) == HIGH) {
backward();
} else {
stop();
}
}