Smart Robot Car v4.0(Elegoo kit)

#include <IRremote.h>

const int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
irrecv.enableIRIn();

pinMode(3, OUTPUT);
pinMode(5, OUTPUT);
}

void loop() {
if (irrecv.decode(&results)) {
if (results.value == 0xFF30CF) {
executeActions();
}
irrecv.resume();
}
}

void moveForward(int speed, int duration) {
analogWrite(3, speed);
analogWrite(5, speed);
delay(duration);
analogWrite(3, 0);
analogWrite(5, 0);
}

void turnRight(int speed, int duration) {
analogWrite(3, speed);
analogWrite(5, 0);
delay(duration);
analogWrite(3, 0);
analogWrite(5, 0);
}

void turnLeft(int speed, int duration) {
analogWrite(3, 0);
analogWrite(5, speed);
delay(duration);
analogWrite(3, 0);
analogWrite(5, 0);
}

void executeActions() {
moveForward(255, 4000);
delay(500);

turnRight(255, 700);
delay(500);

moveForward(255, 2000);
delay(500);

turnLeft(255, 1400);
delay(500);

moveForward(255, 4000);

I loaded this code into the robot(Smart Robot Car v4.0) and it crashed. After loading it only the right side is spinning. How can I load the default settings into it? The manuals are too obscure.

What’s your question ?

Also, add code tags after reading the sticky post ‘How to get the best from the forum,”

1 Like

Hi! Welcome to the forum.

meaning?

Check the connections of the motor driver to pins 3 and 5 of the Uno.

You need to upload the program (.ino file) that was inside it off the shelf. Which program was that? Maybe Elegoo site has it available for you to dowload. Common Unos use to come with the blink program (blinks the onboard LED each 1 sec). This one is available under the examples menu of the Arduino IDE.

If you load code with arbitrary pin numbers you will get arbitrary behavior of code...

Hello people! Are there any gurus in writing code for this robot? We've been given a task at uni:
To drive 2 meters forward.
Turn right 90 degrees.
Drive 1 meter forward
Turn 180 degrees
Drive 2 meters forward
Please help me, this is an urgent matter.

@syimyk122 ,

Your two or more topics on the same or similar subject have been merged.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

Try https://github.com/ArminJo/PWMMotorControl or https://github.com/ArminJo/Arduino-RobotCar.