78Views4Replies

Author Options:

How to make a motor related arduino code? Answered

I need a proper program in which I have 2 motors in which I need to make turns by reducing the speed of one motor and then come back to normal. Please I need help!

Discussions

0
None
iceng

4 years ago

Help is a function of what you can understand.

What is your coding skill ?

And your electronic know how ?

What are your answers to maewert ?

0
None
Shaurya302000iceng

Answer 4 years ago

to add to maewert's answers, I am using a Arduino UNO board. The motor shield has been fixed on it

0
None
maewert

4 years ago

How are you controlling the motors? Are you using a motor shield? Are they stepper motors or plain DC motors? Are you using Pulse Width Modulation to change the motor speed?

0
None
Shaurya302000maewert

Answer 4 years ago

I am using a L293D motor shield, I have been working on a code. check it out

#include <ArduinoRobot.h>
#include <Wire.h>
#include <SPI.h>

void setup() {
// initialize the robot
Robot.begin();
}

void loop() {
Robot.motorsWrite(255, 255); // move forward
delay(2000);
Robot.motorsStop(); // fast stop
delay(1000);
Robot.motorsWrite(-255, -255); // backward
delay(1000);
Robot.motorsWrite(0, 0); // slow stop
delay(1000);
Robot.motorsWrite(-255, 255); // turn left
delay(2000);
Robot.motorsStop(); // fast stop
delay(1000);
Robot.motorsWrite(255, -255); // turn right
delay(2000);
Robot.motorsStop(); // fast stop
delay(1000);
}

its not compiling and giving an error. Any mistakes?