Making the motors to run

Hi guys,

Sorry for the newbish post...
I'm at work right now, and I can't test this code on my board.
Could you tell me if this code will be enough just to get my engines to run forward?

Thank you for your time,

int M1PWM = 9;
int M1DIR = 2;
int M2PWM = 11;
int M2DIR = 3;
int speed = 127; // 1..255

void Setup()
{
pinMode(M1PWM, OUTPUT);
pinMode(M1DIR, OUTPUT);
pinMode(M2PWM, OUTPUT);
pinMode(M2DIR, OUTPUT);
Serial.Begin(9600);
}

void HLHL () // Forward
{
analogWrite(M1PWM, speed);
digitalWrite(M1DIR, LOW);
analogWrite(M2PWM, speed);
digitalWrite(M2DIR, LOW);
}

void loop ()
{
HLHL();
}

dostoievski:
Could you tell me if this code will be enough just to get my engines to run forward?

Not without trying it out. And you are best placed to do that.

...R

It looks good, but there are so many variables that would have to be considered that only you can test.

ProgressiveAuto:
It looks good, but there are so many variables that would have to be considered that only you can test.

It is not just a question of the variables. There is also the wiring and the power supply.

...R

What motors? What motor driver? How are they wired to the Arduino?

Please post your actual code (with "setup" rather than "Setup" for instance).

Try and see, without code, wiring specs of components, nobody can help properly,

Hi guys,

The code was good, the engines started, and everything was in order.
Im trying to build a maze solving line follower. Im using the Arduino Uno just to test the code because I couldn't figure out why the programming pins from my board to Arduino aren't working.
As a driver, I'm using a DRV8835.
Last night I was also able to power up the sensors (https://www.pololu.com/product/1419).
Do you have any idea why the sensors power up on my board but when i connect them to the Arduino board they do not start...?
I've attached the schematis.
Please reply if you have any ideas :slight_smile:

Cheeers :slight_smile:

Job2.PDF (199 KB)

dostoievski:
Do you have any idea why the sensors power up on my board but when i connect them to the Arduino board they do not start...?

That suggests there should be two schematics - one for your board and one for the Arduino board ?

...R

You have a GSM shield. Do you have an adequate power supply for it? They take amps.

Hi guys,

I've managed to get the robot to go forward by reading from the IR sensors.
Now I'm working on the maze solving code which is a bit tricky...
Yes, I'm using a GSM shield to send an SMS when the maze is finished, but I did not attach it yes, because the maze isn't solved yet.

Tx for the support :slight_smile: