I have 2 G2 units so I set unit B to I2C address 12 (even tried 15) via the windows command console. However, with the Arduino setMotorSpeed function, nothing happens to the motor other than when I use address 13.
How do I get it to work.
The code is simple, straight from the example
void setMotorSpeed(int16_t speed)
uint8_t cmd = 0x85; // Motor forward
if (speed < 0)
cmd = 0x86; // Motor reverse
speed = -speed;
Wire.write(speed & 0x1F);
Wire.write(speed >> 5 & 0x7F);
I set smcDeviceNumber=12 (or whatever the setting is) and nothing happens.
Can you successfully move your motor using the slider in the “Status” tab of the Simple Motor Control Center G2? Also, are any errors showing that they are stopping the motor (or have a non-zero count) in that same tab of the control center?
If you set
smcDeviceNumber to 13, does your program work with your SMC G2 that is still using the default device number (which is 13)? Could you post pictures of your setup that show all of your connections? Also, could you post a copy of the settings files from each of your SMC G2 controllers (indicating which one is which)? You can save a copy of the settings file from the “File” drop-down menu of the Simple Motor Control Center G2.
If I use the center, the motor moves, but it is using a usb, not i2c, so I don’t see the relation.
This is on an Arduino. I posted my code and I only change the i2c number to make either work or not work (obviously changing the configuration). There are only 3 connections, the 2 i2c and one gnd. The motor power comes through the VIN end.
Attached is the setting file (if I can figure out how)
# Pololu Simple Motor Controller G2 settings file.
I got it to work, but I honestly don’w know what I did to make it work. Since I have multiple G2 devices connected together on the i2c link, I just tried each separately, then together, then with and without the i2c connections. Put it all back the way I started and it all magically started working again.
That is strange, but I am glad you got it working. Thank you for letting us know.
My guess would be that it was a connection issue; for example, maybe there was an intermittent connection in one of your wires or from a breadboard, if you are using one, but it’s hard to say for sure.