Guide for Using the Mini I2C Motor Driver with the MKR WIFI 1010
Introduction
In robotics and automation, precise motor control is a fundamental necessity. The Mini I2C Motor Driver, when combined with the versatile MKR WIFI 1010 board from Arduino, provides an efficient solution for controlling motors in various applications. This guide aims to equip you with the knowledge to integrate these two components.
Prerequisites
Hardware Setup
MKR WIFI 1010 to Mini I2C Motor Driver Connection
- Connect the SDA (Serial Data Line) and SCL (Serial Clock Line) pins of the MKR WIFI 1010 to the corresponding SDA and SCL pins on the motor driver.
- Ensure the power connections match the requirements of your motors.
Motor Connections
- Attach the motors to the designated terminals on the motor driver.
Software Setup
Installing the Library
- Download and install the library using → MKR_MINI_I2C_Libraray.
- Open the Arduino IDE, go to Documents> Arduino> Libraries, and paste the downloaded folder.
Install the Board Package
- In the Boards Manager, type “MKR WIFI 1010” into the search bar.
- You will see an entry for the MKR WIFI 1010 board, which is usually part of a package like “Arduino SAMD Boards”.
- Click the “Install” button next to the package description. This will install the board support package, which includes the necessary drivers and files.
Select Your Board
- Connect your MKR WIFI 1010 to your computer using a USB cable.
- Go to ‘Tools’ > ‘Port’ and select the port that your MKR WIFI 1010 is connected to. It should be labeled with the board’s name.
- Click the “Install” button next to the package description. This will install the board support package, which includes the necessary drivers and files.
Select Your Port
- Connect your MKR WIFI 1010 to your computer using a USB cable.
- Go to ‘Tools’ > ‘Port’ and select the port that your MKR WIFI 1010 is connected to. It is normally labeled with the board’s name
Loading the Example Code
- Copy the example code given below.
#include <Wire.h>
#include <SparkFunMiniMoto.h>
MiniMoto motor(0x60);
MiniMoto motor1(0x65);
void setup() {
Serial.begin(9600);
Serial.println("MiniMoto Test");
Wire.begin();
}
void loop() {
byte fault = motor.getFault();
if (fault) {
Serial.print("Fault: ");
Serial.println(fault, HEX);
} else {
Serial.println("Driving forward");
motor.drive(100);
motor1.drive(100);
delay(1000);
Serial.println("Driving Backward");
motor.drive(-100);
motor1.drive(-100);
delay(1000);
Serial.println("Stopping");
motor.stop();
motor1.stop();
delay(1000);
}
}
Uploading and Running the Code
- Click `Upload` to compile and transfer the code to the board
- Once uploaded, the motors should respond according to the programmed instructions.
Note: The sample code runs the two motors in one direction for 1 second, another direction in the next second, and stops for a second.
Demo Video
For further inquiries or suggestions, please feel free, to reach out:
- Email: kumarasenau@gmail.com
- GitHub Repository: https://github.com/udarabs-1/MKR_I2C_driver
Contact us for any consultations or projects related to IoT.
Protonest for more details.
Protonest specializes in transforming IoT ideas into reality. We offer prototyping services from concept to completion. Our commitment ensures that your visionary IoT concepts become tangible, innovative, and advanced prototypes.
Our Website: https://www.protonest.co/
Email: udara@protonest.co
If you enjoyed this article and would like to show some support, consider buying me a coffee on Ko-Fi.
Your support not only helps me keep creating content like this but also fuels me! ☕️📚
Thank you for being an amazing reader!
Here’s my Ko-Fi link: https://ko-fi.com/udarakumarasena
Cheers!