This project shows you how to build your own I2C DC motor drive using a DigiSpark Attiny85 plus Arduino motor shield. To test its operation, I made a small RC car which used an M5StickC & connected to Blynk App. to communicate with this drive via the I2C protocol.
Please check my introduction video before getting started.
Step 1: Supplies
First of all, I would like to thank the JLCPCB for supporting me on this project. If you have a PCB project, please visit the JLCPCB website to get exciting discounts and coupons as follows:
a. Main materials:
⦾ 1pcs x M5StickC.
⦾ 1pcs x DigiSpark ATTiny85.
⦾ 1pcs x Quad DC Motor Driver Shield for Arduino.
⦾ 1pcs x Arduino Uno Protoshield.
⦾ 1pcs x 2 Slot Battery 18650 Holder.
⦾ 2pcs x Rechargeable Li-ion Battery 18650.
⦾ 4pcs x Copper Standoff Spacers 20mm.
⦾ 1 meter x 8P/16P Rainbow Ribbon Cable.
⦾ 2 pcs x R10K.
⦾ 1pcs x XH2.54mm – 4P 10cm Wire Cable Double Connector.
⦾ 1pcs x Grove Connector.
⦾ 1 meter x Two Core Power Cable.
⦾ Cable spiral wrap, bolts and nuts.
⦾ Hot glue gun.
⦾ Soldering machine.
Step 2: Schematic
Main control components include: M5StickC, DigiSpark Attiny85, DFRobot Quad DC Motor Driver Shield for Arduino. And their connection is as below:
I used two communications in this project to control four DC motors of a RC car:
- M5StickC gets Blynk joystick command from smartphone via WIFI and converts it to car direction and speed.
- After that M5StickC transmits these converted commands to Attiny85 via I2C protocol. Finally, after receiving command, Attiny85 send its output signals to Quad motor shield to control direction and speed of car DC motors.
- In the schematic, I used 2 pull-up resistors R10K on the SDA and SCL line.
- For the quad motor shield, I connected each group consisting of 2 DC motors in parallel at the M1 & M2 screw terminals. DIR signal of motor M1 & M2 has been connected together at motor shield pin 4 & 12. So I have controlled four DC motors with only 3 signals.
Step 3: Car Assembly
After using stepper motors for mini CNC projects, there are still some DC motors left in the CD/DVD player. They are used to insert or eject CD/ DVD plastic tray.
I disassembled four DC motors, soldered them on the double sided protoboard 7x9cm.
I found some wheels from small toy cars that have a center bore equal to the 2mm motor shaft diameter.
I used another protoboard 7x9cm then soldered on it a step-down power supply module LM2596, a power switch, a 2-pin screw header and 4 male header groups that match correspondingly to all the pins of the Quad DC Motor Shield for Arduino.
The LM2596 output terminals were connected to male headers at pin 5V and GND. It is used to power all the control circuits after I stack all the boards on these headers.
I connected wires for battery holder, module LM2596, motor shield power supply and 4 DC motors.
The main control circuit was soldered on an Arduino protoshield following the schematic on previous step, as follow:
⦾ Protoshield bottom includes: Attiny85 header (black), 4-pins I2C header (white) and motor shield headers (4 group – black).
⦾ Protoshield top includes: M5StickC 8 pin-header.