hey, does you use 0023 to driver it?
And if all leds are lighted , maybe you need modify its’ code
maybe you could try these code
[code]#include <Wire.h>
//#define MOTORSHIELDaddr 0x0f
#define SETPWMAB 0x82
#define SETFREQ 0x84
#define CHANGEADDR 0x83
#define CHANNELSET 0xaa
#define MOTOR1 0xa1
#define MOTOR2 0xa5
#define SAVEADDR ‘S’
#define NOTSAVEADDR ‘N’
static unsigned char MOTORSHIELDaddr = 0x28;
void speedAB(unsigned char spda , unsigned char spdb)
{
Wire.beginTransmission(MOTORSHIELDaddr); // transmit to device MOTORSHIELDaddr
Wire.send(SETPWMAB); //set pwm header
Wire.send(spda); // send pwma
Wire.send(spdb); // send pwmb
Wire.endTransmission(); // stop transmitting
delayMicroseconds(100);
}
void fre_pre(unsigned char pres)
{
Wire.beginTransmission(MOTORSHIELDaddr); // transmit to device MOTORSHIELDaddr
Wire.send(SETFREQ); // set frequence header
Wire.send(pres); // send prescale
Wire.send(0); // need to send this byte as the third byte(no meaning)
Wire.endTransmission(); //
delayMicroseconds(100);
}
void change_adr(unsigned char new_adr, unsigned char save_or_not)
{
Wire.beginTransmission(MOTORSHIELDaddr); // transmit to device MOTORSHIELDaddr
Wire.send(CHANGEADDR); // change address header
Wire.send(new_adr); // send new address
Wire.send(save_or_not); // save the new address or not
Wire.endTransmission(); //
delayMicroseconds(100); //this command needs at least 6 us
}
void channel(unsigned char i4) //0b 0000 I4 I3 I2 I1
{
// delayMicroseconds(4);
Wire.beginTransmission(MOTORSHIELDaddr); // transmit to device MOTORSHIELDaddr
Wire.send(CHANNELSET); // channel control header
Wire.send(i4); // send channel control information
Wire.send(0); // need to send this byte as the third byte(no meaning)
Wire.endTransmission(); //
}
void motorAndspd( unsigned char motor_s,unsigned char Mstatus, unsigned char spd)
{
Wire.beginTransmission(MOTORSHIELDaddr); // transmit to device MOTORSHIELDaddr
Wire.send(motor_s); // motor select information
Wire.send(Mstatus); // motor satus information
Wire.send(spd); // motor speed information
Wire.endTransmission(); //
delayMicroseconds(100);
}
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
delayMicroseconds(10); //wait for motor driver to initialization
}
void loop()
{
motorAndspd(0xa1,0b01,225);
motorAndspd(0xa5,0b01,30);
delay(2000);
motorAndspd(0xa5,0b10,225);
motorAndspd(0xa1,0b10,30);
delay(2000);
change_adr(0x12, NOTSAVEADDR );
MOTORSHIELDaddr = 0x12;
for( int i = 0;i< 16;i++)
{
fre_pre(i);
channel(i);
delay(100);
}
speedAB(0 , 0);
change_adr(0x28,NOTSAVEADDR );
MOTORSHIELDaddr = 0x28;
}[/code]