help with basic motor coding

Hi, I am a complete beginner and I have no clue what I am doing. My code compiles, but when I run it, the motors go, but it doesn't stop. I used an LD293D chip

const int leftmotorin1=9; const int leftmotorin2=8; const int rightmotorin1=5; const int rightmotorin2=4;

void setup() { pinMode(leftmotorin1,OUTPUT); pinMode(leftmotorin2,OUTPUT); pinMode(rightmotorin1,OUTPUT); pinMode(rightmotorin2,OUTPUT); }

void loop () { forward(200); delay(1000); forward(0); } void forward(int Speed) { analogWrite(leftmotorin1,Speed); analogWrite(leftmotorin2,0); analogWrite(rightmotorin1,Speed); analogWrite(rightmotorin2,0); }

The motor shield has two direction pins that should be set using digitalWrite() and two speed pins that should be set using analogWrite().


thanks, I am still not entirely sure what to change

I am still not entirely sure what to change

Two of your analogWrite() statements need to be digitalWrite()s.

Put some spaces in the function calls, to the argumentsdontallwruntogether.