background image

  
Code developed in Arduino 1.0.5, on a Fio classic board. 
  
**Updated for Arduino 1.6.4 5/2015** 
****************************************************************/ 
  
#include <SparkFunMiniMoto.h>  // Include the MiniMoto library 
  
// Create two MiniMoto instances, with different address settings. 
MiniMoto motor0(0xC4); // A1 = 1, A0 = clear 
MiniMoto motor1(0xC0); // A1 = 1, A0 = 1 (default) 
  
#define FAULTn  16     // Pin used for fault detection. 
  
// Nothing terribly special in the setup() function- prep the 
//  serial port, print a little greeting, and set up our fault 
//  pin as an input. 
void setup() 

    Serial.begin(9600); 
    Serial.println("Hello, world!"); 
    pinMode(FAULTn, INPUT); 

  
// The loop() function just spins the motors one way, then the 
//  other, while constantly monitoring for any fault conditions 
//  to occur. If a fault does occur, it will be reported over 
//  the serial port, and then operation continues. 
void loop() 

    Serial.println("Forward!"); 
    motor0.drive(100); 
    motor1.drive(100); 
    delayUntil(1000); 
    Serial.println("Stop!"); 
    motor0.stop(); 
    motor1.stop(); 
    delay(1000); 
    Serial.println("Reverse!"); 
    motor0.drive(-100); 
    motor1.drive(-100); 
    delayUntil(1000); 
    Serial.println("Brake!"); 
    motor0.brake(); 
    motor1.brake(); 
    delay(1000); 

  
// delayUntil() is a little function to run the motor either for 
//  a designated time OR until a fault occurs. Note that this is 
//  a very simple demonstration; ideally, an interrupt would be 
//  used to service faults rather than blocking the application 
//  during motion and polling for faults. 
void delayUntil(unsigned long elapsedTime) 

    // See the "BlinkWithoutDelay" example for more details on how 
    //  and why this loop works the way it does. 
    unsigned long startTime = millis(); 
    while (sta elapsedTime > millis()) 
    { 
        // If FAULTn goes low, a fault condition *may* exist. To be 
        //  sure, we'll need to check the FAULT bit. 
        if (digitalRead(FAULTn) == LOW) 
        { 

Summary of Contents for Mini I2C

Page 1: ...ck EMF It features two LEDs for fault indicator and four LEDs to indicate which direction each motor is running GROVE system plug and I2C interface enables you to daisy chain the driver with many othe...

Page 2: ...ut output voltage on I2C bus 3 3 5 V Communication protocol I2C Interface Function Grove Interface Grove products have a eco system and all have a same connector which can plug onto the Base Shield Co...

Page 3: ...r direction indicator CH1 Output Connector Motor 1 connector CH2 Output Connector Motor 2 connector Hardware function Change Default maximum drive current The default maximum drive current of each cha...

Page 4: ...the board Caution Maximum working current of each channel should not be more than 1A So the minimum value of resistor soldered to the reserved pad should not less than 0 2 Change Default I2 C Address...

Page 5: ...rations Now we are making a demo for Grove Mini I2C Motor Driver v1 0 which require following modules 2 DC Motor 2V 6V Seeeduino Lite Seeeduino Lite is compatible with Arduino If you are using an Ardu...

Page 6: ...o forwards and backwards but also turn around by having each wheel spin in a different direction Connect Seeeduino to computer use a micro USB cable Now let s use the Grove Mini I2C Motor Driver to co...

Page 7: ...serial port and then operation continues void loop Serial println Forward motor0 drive 100 motor1 drive 100 delayUntil 1000 Serial println Stop motor0 stop motor1 stop delay 1000 Serial println Revers...

Page 8: ...otion in response to our fault result motor1 getFault if result FAULT Serial print Motor 1 fault if result OCP Serial println Chip overcurrent if result ILIMIT Serial println Load current limit if res...

Reviews: