Motion of BOLT IOT device

Hlo,

when I assembled my robot and made it start moving.I coded as 

void forward(){
digitalWrite(4,HIGH);
digitalWrite(7,LOW);
digitalWrite(12,HIGH);
digitalWrite(8,LOW);
}

This code is for forward movement but when I uploaded it , it started moving in reverse .I don’t know the reason why it is moving like this.

also

void setup{

digitalWrite(4,HIGH);

}

When I write this the left tyre is moving in reverse.

Could you please solve my problem.

Your motors were setup incorrectly.

Solution (any of the below) -

  1. If you can, redo the hardware process and setup the motors in correct position. Run the code and check which way it moves for avoiding similar issues in future.
  2. Write the code so that it does the opposite job. For the wheels to move forward, write a reverse code in forward. And vice versa.

thank you so much,
but 1st solution is not working.I go with second.

1 Like

To avoid these kind of issues, use motor drivers like L298N or L2N3D.
The H Bridge connection willl let you control the motors both ways.

Let me know if you need any more information.

when uploaded the code i.e
stop();
delay(2000);
forward();
delay(2000);
reverse();
delay(2000);
left();
delay(2000);
right();
delay(2000);
left_forward();
delay(2000);
right_forward();
delay(2000);
left_reverse();
delay(2000);
right_reverse();
delay(2000);
in loop and I removed the usb cable and connected with the adaptar but tyres are moving in forward direction only and not moving reverse,not performing any other functions like left,right,left_forward…etc

Can you share the complete code and send a snap of your connection?

Are you using drivers to run the motor or have you directly connected them to the Arduino?

add a stop command for ex.
forward();
delay(2000);
stop();
delay(500);
reverse();
delay(2000);
after forward, reverse ,right and left so that instant channel reversal does not happen.

1 Like

this is the complete code
as i said before a problem that is if i write code digitwrite(4,HIGH); the left tyre is moving reverse.So by that I wrote code in opposite sense

void stop(){
digitalWrite(4,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(12,LOW);
}
void forward(){
digitalWrite(4,LOW);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(12,LOW);
}
void reverse(){
digitalWrite(4,HIGH);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(12,HIGH);
}
void left(){
digitalWrite(4,HIGH);
digitalWrite(7,LOW);
digitalWrite(8,HIGH);
digitalWrite(12,LOW);
}
void right(){
digitalWrite(4,LOW);
digitalWrite(7,HIGH);
digitalWrite(8,LOW);
digitalWrite(12,HIGH);
}
void leftforward(){
digitalWrite(4,LOW);
digitalWrite(7,LOW);
digitalWrite(8,HIGH);
digitalWrite(12,LOW);
}
void rightforward(){
digitalWrite(4,LOW);
digitalWrite(7,HIGH);
digitalWrite(8,LOW);
digitalWrite(12,LOW);
}
void leftreverse(){
digitalWrite(4,HIGH);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(12,LOW);
}
void rightreverse(){
digitalWrite(4,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(12,HIGH);
}
void setup() {
// put your setup code here, to run once:
pinMode(5,OUTPUT);
pinMode(4,OUTPUT);
pinMode(7,OUTPUT);
pinMode(6,OUTPUT);
pinMode(8,OUTPUT);
pinMode(12,OUTPUT);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
}

void loop() {
// put your main code here, to run repeatedly:
stop();
delay(2000);
forward();
delay(2000);
reverse();
delay(2000);
left();
delay(2000);
right();
delay(2000);
leftforward();
delay(2000);
rightforward();
delay(2000);
leftreverse();
delay(2000);
rightreverse();
delay(2000);

}

these are photos of my robot

if I use this code,It works upto right but not for left forward,right forward,left reverse and right reverse
forward();
delay(2000);
stop();
delay(500);
reverse();
delay(2000);
left();
delay(2000);
stop();
delay(500);
right();
delay(2000);

Thanks,If I run these it works finely…

forward();
delay(2000);
stop();
delay(500);
reverse();
delay(2000);
left();
delay(2000);
stop();
delay(500);
right();
delay(2000);
stop();
delay(500);
leftforward();
delay(2000);
rightforward();
delay(2000);
stop();
delay(500);
leftreverse();
delay(2000);
rightreverse();
delay(2000);

1 Like