16. System Integration¶
The Motor Driver¶
First Step “Test”¶
🛸 Control a Coreless Motor with MX1508 + XIAO RP2040 + 3.7V LiPo
This guide explains how to control a coreless motor (6x15mm) using the MX1508 motor driver, a XIAO RP2040, and a 3.7V 1800mAh LiPo battery.
✅ Components¶
Component | Specs / Notes |
---|---|
Motor | 6×15mm coreless, ~3.7V, ~70,000 RPM |
Motor Driver | MX1508 Dual H-Bridge |
Microcontroller | XIAO RP2040 (3.3V logic) |
Battery | 3.7V 1800mAh LiPo |
⚠️ Compatibility Check¶
Feature | Status ✅ / ⚠️ | Notes |
---|---|---|
MX1508 input voltage | ✅ | 2V–10V, OK with 3.7V LiPo |
Motor voltage | ✅ | Suitable for 3.7V |
Logic level (PWM from RP2040) | ✅ | MX1508 works with 3.3V signals |
Motor current vs MX1508 | ⚠️ | Ensure draw < 1.5A per channel (typical OK) |
🔌 Wiring Diagram¶
[LiPo 3.7V +] -----> MX1508 VCC
[LiPo GND] ---------> MX1508 GND and XIAO GND
XIAO D6 (PWM) ------> MX1508 IN1
XIAO D7 (PWM) ------> MX1508 IN2
MX1508 OUT1 --------> Motor +
MX1508 OUT2 --------> Motor -
🧠 Arduino Code Example¶
Make sure to install XIAO RP2040 support in the Arduino IDE.
int motorPin1 = 6; // IN1
int motorPin2 = 7; // IN2
void setup() {
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
}
void loop() {
// Forward rotation
analogWrite(motorPin1, 150); // Speed (0–255)
analogWrite(motorPin2, 0);
delay(2000);
// Stop
analogWrite(motorPin1, 0);
analogWrite(motorPin2, 0);
delay(1000);
// Backward rotation
analogWrite(motorPin1, 0);
analogWrite(motorPin2, 150);
delay(2000);
}
🔋 Battery Notes¶
- Battery: 3.7V 1800mAh LiPo
- Typical C-rating: ~20C (estimate)
- Max Current Output:
[ 1.8A × 20C = 36A peak (enough for multiple motors) ] - Protect battery: Don’t discharge below 3.3V
Optional: - Add a voltage divider for monitoring battery level via XIAO - Or use a LiPo buzzer for low voltage alarm
✅ Steps Summary¶
- Connect battery to MX1508 VCC and GND.
- Connect XIAO GND to MX1508 GND.
- Connect PWM pins from XIAO to IN1, IN2 of MX1508.
- Connect motor to OUT1 and OUT2.
- Upload Arduino code to control direction and speed.
- Power up and test!