Hi @francoisgonothitoure, I think i get your problem. I was also facing the same problem. The problem was in my code, for the robot to work properly with DC adapter only we need to
Add stop and delay of 500 millisecond after each function call in between our code.
You also didn’t include the delay and stop functions in the code, if I’m not mistaken.
The DC motor used in our project has a 12 volt operating voltage. The robot requires extra power to operate because it has two motors and a motor driver IC, so when the adapter and USB are connected at the same time, the robot receives the correct power and functions as intended.
When the adapter is the only thing connected, the first function can be called without any issues, but when it tries to call the second function, it can’t acquire enough power for a sudden transition. A built-in reset is provided on the Boltduino board, allowing it to automatically reset and resume operations when the working environment is insufficient.
Here it is the code for “First Robot” with stop and delay functions included.
void stationary() {
digitalWrite(4,LOW);
digitalWrite(7,LOW);
digitalWrite(12,LOW);
digitalWrite(8,LOW);
}
void forward() {
digitalWrite(4,HIGH);
digitalWrite(7,LOW);
digitalWrite(12,HIGH);
digitalWrite(8,LOW);
}
void reverse() {
digitalWrite(4,LOW);
digitalWrite(7,HIGH);
digitalWrite(12,LOW);
digitalWrite(8,HIGH);;
}
void left() {
digitalWrite(4,HIGH);
digitalWrite(7,LOW);
digitalWrite(12,LOW);
digitalWrite(8,HIGH);
}
void right() {
digitalWrite(4,LOW);
digitalWrite(7,HIGH);
digitalWrite(12,HIGH);
digitalWrite(8,LOW);
}
void left_forward() {
digitalWrite(4,LOW);
digitalWrite(7,LOW);
digitalWrite(12,HIGH);
digitalWrite(8,LOW);
}
void right_forward() {
digitalWrite(4,HIGH);
digitalWrite(7,LOW);
digitalWrite(12,LOW);
digitalWrite(8,LOW);
}
void left_reverse() {
digitalWrite(4,LOW);
digitalWrite(7,HIGH);
digitalWrite(12,LOW);
digitalWrite(8,LOW);
}
void right_reverse() {
digitalWrite(4,LOW);
digitalWrite(7,LOW);
digitalWrite(12,LOW);
digitalWrite(8,HIGH);
}
void setup() {
// put your setup code here, to run once:
pinMode(5,OUTPUT); //Enable pin for left motor will receive 5V and motor sheild will convert it into 12V supply
pinMode(4,OUTPUT); //Pin declaration for control pin 1 of left motor
pinMode(7,OUTPUT); //Pin declaration for control pin 2 of left motor
pinMode(6,OUTPUT); //Enable pin for right motor will receive 5V and motor sheild will convert it into 12V supply
pinMode(12,OUTPUT); //Pin declaration for control pin 1 of right motor
pinMode(8,OUTPUT); //Pin declaration for control pin 2 of right motor
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
stationary();
delay(5000);
forward();
delay(5000);
stationary();
delay(500);
reverse();
delay(5000);
stationary();
delay(500);
left();
delay(5000);
stationary();
delay(500);
right();
delay(5000);
stationary();
delay(500);
left_forward();
delay(5000);
stationary();
delay(500);
right_forward();
delay(5000);
stationary();
delay(500);
left_reverse();
delay(5000);
stationary();
delay(500);
right_reverse();
delay(5000);
stationary();
delay(500);
}
Hope this was helpful. If you still can’t fix the problem, please tag me and if you can, please respond as well