Pololu Low Voltage Dual serial motor Controller programming help !

I am having a problem with programming my pololu Low voltage dual serial motor controller http://www.pololu.com/catalog/product/120 if anyone could find what is wrong with my code that would be awesome, it has no compling issuses but it cant drive any motors. Below is my code

int rstPin = 2; // Reset Port connected to digital pin 2

void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps pinMode(rstPin, OUTPUT); // sets the digital reset pin as output

Serial.write((byte)0x80); Serial.write((byte)0x02); Serial.write((byte)02000000); delay; 1000; }

void loop() {

digitalWrite(rstPin, HIGH); // sets the sets rst pin on full to continue

Serial.write((byte)0x80); Serial.write((byte)0x00); Serial.write((byte)00000011); Serial.write((byte)0x7F);

}

I think some of your problem is that you are confusing Octal constants with binary constants...

The numbers that appear doubtful in your sketch are

02000000 = very octal large number that will not fit in a byte - i do not know what was intended here :(

(but I think it will set the controller to expect two motors, called 0 and 1).

00000011 is an octal constant, that looks like it was meant to be binary.

i think your sketch might work better with B00000011 instead to indicate the number is in binary.

I am not sure, but I think that you should set the reset pin in setup() and not change it afterwards.

Hope this helps, and that if you do read the below it does not confuse you.

Regards Dafid

=========================================

In C (and C++ ) a number (for example 255 the largest byte value) can be:

Decimal (base 10 ) - is digits starting with 1 2 3 4 5 6 7 8 or 9 so 255 = 2*10*10 + 5*10 + 5 Octal (base 8 ) - is made up of digits 0 to 7, starting with 0 so 0177 = 1*8*8 + 7*8 + 7 HEX (base 16 ) - is made up of 0-9 plus a-f, starting with 0x so 0xff = 15*16 + 15 (a=10, b=11, c=12,..., f=15 )

There is no binary in standard C or C++, but there is in Arduino :)

Binary (base 2) - is digits either 0 or 1 starting with a B, so 255 = B11111111 = 1*128+1*64+1*32+1*16+1*8+1*4+1*2+1

You didn’t read the manual properly ( bottem of page 7 of manual), you must flash the reset line after initialisation.
Also a while(1) at the end of your void loop would help with testing. Also check your wiring again. It took a whole rainy Sunday afternoon but I got mine working, eventually. Here is my code.

#include <SoftwareSerial.h>

#define txmotor 1
#define rxmotor 0
#define resmotor 4
SoftwareSerial motors = SoftwareSerial (txmotor, rxmotor);

void setup()
{
delay(20);
pinMode (resmotor, OUTPUT);
Serial.begin(9600);
digitalWrite(resmotor, HIGH);
delay(20);
Serial.print(128,BYTE);
Serial.print(2,BYTE);
Serial.print(2,BYTE);
delay(20);
mflash();
}
void loop()
{

mforwards(); // or use mbackwards or mrotright or mrotleft

while(1);
}

void mforwards()
{
mflash();
byte movement = {128,0,5,127,128,0,7,127};
for (int i=0; i<sizeof(movement); i++) {
Serial.print(movement*,BYTE);*
}
}
void mbackwards()
{
mflash();
byte movement[] = {128,0,4,127,128,0,6,127};
for (int i=0; i<sizeof(movement); i++) {
_ Serial.print(movement*,BYTE);_
_
}_
_
}_
void mrotright()
_
{_
mflash();
byte movement[] = {128,0,4,127,128,0,7,127};
for (int i=0; i<sizeof(movement); i++) {
_ Serial.print(movement,BYTE);
}
}
void mrotleft()
{
mflash();
byte movement[] = {128,0,5,127,128,0,6,127};
for (int i=0; i<sizeof(movement); i++) {
Serial.print(movement,BYTE);
}
}
void mflash()
{
digitalWrite(resmotor, LOW);
delay(20);
digitalWrite(resmotor, HIGH);
delay(20);
}*_