Changing Address of MD25 motor controller

I am trying to change the address of one of my MD25 motor controller with no success. Please see my syntax below. …Where have I gone wrong?************

#include “Wire.h”
#include <LiquidCrystal.h>

int currentDeviceId = 0x58; //Current Address
int newDeviceId = 0x59; //New Address

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // initialize the library with the numbers of the interface pins

void setup()
{
Wire.begin();
configureDeviceId;
}

void loop()
{
lcd.begin(16, 2); // set up the LCD’s number of rows and columns:
lcd.print("Decimal Read ");
lcd.print(newDeviceId);

lcd.setCursor(0, 1); // (note: line 1 is the second row, since counting begins with 0):
lcd.print("For Hex: 0x59 ");
delay(1000);
}

void configureDeviceId(int currentDeviceId, int newDeviceId)
{
Wire.beginTransmission(currentDeviceId);
Wire.send(16);
Wire.send(0xA0);
Wire.endTransmission();

Wire.beginTransmission(currentDeviceId);
Wire.send(16);
Wire.send(0xAA);
Wire.endTransmission();

Wire.beginTransmission(currentDeviceId);
Wire.send(16);
Wire.send(0xA5);
Wire.endTransmission();

Wire.beginTransmission(currentDeviceId);
Wire.send(16);
Wire.send(newDeviceId);
Wire.endTransmission();
}

void setup()
 {
  Wire.begin();
  configureDeviceId (currentDeviceId, newDeviceId);
 }

"configureDeviceId" is simply a pointer that evaluates to non-zero, therefore true, with which you don't do anything.

Please don't cross-post the same problem, and use the Code (#) button when posting code.

I am still problems with changing the address of one of my MD25 motorcontroller. Address is not changing…Please help

#include "Wire.h"
#include <LiquidCrystal.h>

int currentDeviceId = 0x58;                   //Current Address
int newDeviceId = 0x59;                       //New Address



void setup()
 {
  Wire.begin();
 configureDeviceId (currentDeviceId, newDeviceId);
 }

void loop()
 {
 }

void configureDeviceId(int currentDeviceId, int newDeviceId)
{
     Wire.beginTransmission(currentDeviceId);
     Wire.send(16);
     Wire.send(0xA0);
     Wire.endTransmission();
         delay(5);
     Wire.beginTransmission(currentDeviceId);
     Wire.send(16);
     Wire.send(0xAA);
     Wire.endTransmission();
          delay(5);
     Wire.beginTransmission(currentDeviceId);
     Wire.send(16);
     Wire.send(0xA5);
     Wire.endTransmission();
          delay(5);
     Wire.beginTransmission(currentDeviceId);
     Wire.send(16);
     Wire.send(newDeviceId);
     Wire.endTransmission();
}
 

Back to top        /code]

Have you even read the Wire page?

http://www.arduino.cc/en/Reference/Wire

It states that the Wire library uses 7-bit addresses, and some devices require a 8-bit address.

The rest of the reading is up to you!~:)

I am a bit of a newbie, kindly explain more. I have been trying to crack this problem for days now....Thanks!

Have you got communication with the controller? Is it just the address change that doesn't work, or nothing at all?

I would put the 'void configureDeviceId' in setup as well so that it only gets run once.

Forget that last post it’s late and my eyesight is failing me ::slight_smile:

Hi Dele,

Don't know if you are still having problems but the new address you are sending is wrong: int newDeviceId = 0x59; //New Address

The Arduino goes a bit against the grain and shifts the address, try sending a full 8 bit address: int newDeviceId = 0xB2;