Code to run ENG 30?

I am trying to get the proper code to run an EMG 30 motor. This motor is hooked up to an Arduino Uno and Devantech MD25 in I2C configuration. I tried running the sample code from the Devantech website, but could only get the motor to run sporadically. I thought I would start from scratch and learn how to program this motor, so I used the code below:

[code] #include <SoftwareSerial.h>
#include <Wire.h>

void loop(){

Wire.write(150);                                           
delay(3000);

}[/code]
When I run this code, I get the error message: “expected constructor, destructor, or type conversion expected before ‘void’” Could you tell me what additional code I need to add to make the motor run? I’m trying to learn the very basics of controlling the motor by the software, and would like to know just the bare minimum of what code is needed to run one motor - just enough to turn the motor on and off.

I ran the code that you gave in the example, and nothing happened. I have the motors setup in the I2C protocol, but nothing happened when I uploaded the code…the motors did not move. What am I doing incorrectly? The green LED on the MD25 flashes about once per second, alongside the steady red LED on the MD25. I know the motors are working, because once in a while they will run, although I can’t explain why.

You need to initialize your Wire object, see this reference: arduino.cc/en/Reference/Wire

You can inspire yourself form this example:

[code]#include <Wire.h>

void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
}

byte x = 0;

void loop()
{
Wire.beginTransmission(4); // transmit to device #4
Wire.write("x is "); // sends five bytes
Wire.write(x); // sends one byte
Wire.endTransmission(); // stop transmitting

x++;
delay(500);
}[/code]

Also, keep in ming this is for the I2C protocol, you could also use the serial protocol if you are not comfortable with it.

The coded we provided is simply the i2C communication example, you need to modify it to send the correct message to your motor controller.

Please read its specifications in order to learn about its communication protocol.