Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Raspberry Pi and Cytron Motor Driver Controlled Dual DC Motor System

View and Edit Project In Cirkit DesignerImage of Raspberry Pi and Cytron Motor Driver Controlled Dual DC Motor System

Circuit Documentation

Summary

This circuit is designed to control two DC motors using a Cytron motor driver and a Raspberry Pi 3B. The motors are powered by a 12V battery, and the Raspberry Pi sends control signals to the motor driver to manage the speed and direction of the motors.

Component List

Cytron Motor Driver

Battery 12V

DC Motor (Motor 1)

DC Motor (Motor 2)

Raspberry Pi 3B

Wiring Details

Cytron Motor Driver

Battery 12V

DC Motor (Motor 1)

DC Motor (Motor 2)

Raspberry Pi 3B

Code Documentation

Raspberry Pi 3B Code

#define PWM1 9  // Motor 1 PWM
#define DIR1 8  // Motor 1 arah
#define PWM2 10 // Motor 2 PWM
#define DIR2 7  // Motor 2 arah

void setup() {
  // Setup GPIO
  pinMode(PWM1, OUTPUT);
  pinMode(DIR1, OUTPUT);
  pinMode(PWM2, OUTPUT);
  pinMode(DIR2, OUTPUT);
}

void loop() {
  // Motor 1 maju
  digitalWrite(DIR1, HIGH);
  analogWrite(PWM1, 128); // Kecepatan 50% (0-255)
  
  // Motor 2 mundur
  digitalWrite(DIR2, LOW);
  analogWrite(PWM2, 192); // Kecepatan 75% (0-255)
  
  delay(2000);

  // Stop motor
  analogWrite(PWM1, 0);
  analogWrite(PWM2, 0);
  delay(1000);
}

This code sets up the GPIO pins on the Raspberry Pi to control the Cytron motor driver. The setup function initializes the pins, and the loop function controls the motors, making Motor 1 move forward at 50% speed and Motor 2 move backward at 75% speed, then stops both motors after 2 seconds.