Sending Serial Data Via i2C

Hi;

I have built a Robot that is controlled remotely via a control panel on a web page (Left, Right, Forward, Backwards), for vision it has a Web Cam mounted on it. The robot has an Arduino Nano ATMega328P connected to a Raspberry Pi via 2 wire i2c. The motors are connected to and driven by the Nano and the Raspberry Pi serves the Web Page and Web Cam.

The problem I am having is finite control, when I click on Left for instance the motors run too long resulting in the robot spinning too far. What I need to be able to do is have better control.

I have tried reducing the PWM but the motors don't run unless they are on full speed so I need another way of doing this.

Someone suggested using the Millis() command to specify the length of time a function runs for.

Any help with implementing Millis() in this way would be appreciated.

Here is a thread about timing with millis() timing with millis()

JonnyAlpha:
I have tried reducing the PWM but the motors don't run unless they are on full speed so I need another way of doing this.

It sounds like there's something wrong with your setup. What motors are you using? What h-bridge?

Sending serial data via I2C doesn’t make sense.
Asking questions about code you didn’t post doesn’t make sense.

Using millis() may, or may not, be the right answer. Right now, I’d guess that there is some fundamental flaw in the code though, and that delay()/millis() changes will not correct that.