Project issues

I have a DRV8833 motor controller which typically controls two motors but is now controlling just 1 motor.

I tested the below program for arduino:

const int In4 = 11; // In4
const int In3 = 10; // In3
const int In2 = 6; // In2
const int In1 = 5; // In1

void setup()
{
// initialize the pins an output:
pinMode(In1, OUTPUT);
pinMode(In2, OUTPUT);
pinMode(In3, OUTPUT);
pinMode(In4, OUTPUT);
}

void loop()
{
int speed1;
int speed2;
speed1 = 150; // you can use values from 0 to 255
speed2 = 150; // you can use values from 0 to 255
while(1==1)
{
//Go Forward
analogWrite(In4, speed1);
analogWrite(In3, 0);
analogWrite(In2, 0);
analogWrite(In1, speed2);
delay(3000);
//STOP
analogWrite(In4, 0);
analogWrite(In3, 0);
analogWrite(In2, 0);
analogWrite(In1, 0);
delay(1000);
//Reverse
analogWrite(In4, 0);
analogWrite(In3, speed1);
analogWrite(In2, speed2);
analogWrite(In1, 0);
delay(2000);
//STOP
analogWrite(In4, 0);
analogWrite(In3, 0);
analogWrite(In2, 0);
analogWrite(In1, 0);
delay(1000);
}
}

Whenever I try a new program, the motor moves forward for a second and then stops indefinitely.

Please put your code in its own window as seen in other posts. This can be done by placing     [code]  and [/code]  around the code or use the </> icon. This makes it easier for others to read.

How to use this forum

"Whenever I try a new program, the motor moves forward for a second and then stops indefinitely." Do you mean every time you RESTART the program above it moves forward for 1 sec then stops?

Weedpharma

You don't need

while(1==1)
  {

That just duplicates what loop() does.

...R

Robin2:
You don't need

while(1==1)

{



That just duplicates what loop() does.

Unless you are using political terminology. :grinning:

And clearly the "loop" code just prior to this should actually be in setup().

msugandhi:
Whenever I try a new program, the motor moves forward for a second and then stops indefinitely.

Is there example code for that board that works? Can you simply make it go forward and not stop?

This will tell many things from power to hardware if it works or not. Reduce unknowns to troubleshoot.