Let's Make Robots!

arduino code not working the way it should

i made a code ,and the code doesnt work the way it should, it makes the motors go bakwards ,pause, backwards

this isnt what i told it to do, why is this so here is the code , hope you can help cause i want to enter this in the arduino challenge

void setup()
{
  Serial.begin(9600);
  pinMode(13,OUTPUT);
 pinMode(12,OUTPUT);
  pinMode (11,OUTPUT);
  pinMode (10,OUTPUT);
}
  void loop()
{
 driveforward();
 delay(1000);
 stopmot();
 delay (1000) ;
 reverse();
 delay(1000);
 return;
}

void driveforward()
{ digitalWrite(12,HIGH);
  digitalWrite(10,HIGH);
}
void stopmot()
{
  digitalWrite(13,LOW);
  digitalWrite(12,LOW);
  digitalWrite(11,LOW);
  digitalWrite(10,LOW);
}
void reverse()
{
  digitalWrite(13,HIGH);
  digitalWrite(11,HIGH);
}

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

nope this is for my arduino start here robot 

Hello Dimble,

 

Is this the code you used to drive the K243? Forward, stop, and reverse?

 

Hope for your reply.

ferari

cool ill try that now ,thanks
hurrray it works thanks
It will work fine if you set the other 2 pins LOW in driveforward() and reverse() functions. Now you have just the pins that are set HIGH in those functions. Look at the stopmot() function and make sure you have all 4 lines in all functions, but with the pins set accordingly.