JGB37-520 DC Gear Motor: How to Wire and Control It Leave a comment

You have a JGB37-520 DC gear motor and want to spin it with an Arduino. These motors are common in robot cars and automation projects, but they need a driver board and a separate power supply.

This guide walks you through the wiring, the code, and the fixes for the problems that come up most often.

Quick answer

How do I control a JGB37-520 DC gear motor with Arduino?

To control a JGB37-520 DC gear motor with Arduino, connect the motor to an L298N driver, power the driver from a separate battery, and link the driver inputs to Arduino pins. Then use PWM and digitalWrite commands in your code to set speed and direction. This setup works for robot cars and automation projects.

What you need for this build

Gather these parts before you start. Most are available from the Motors, Drivers and Wheels category.

If you are also using servos for steering, the SG90 9g Micro Servo Motor (180 Degree Rotation) (Rs. 320) or the MG90S Metal Gear Servo Motor (180 Degree Rotation) (Rs. 450) are good choices.

Step 1: Mount the motor and prepare the wires

DC Gear Motor Black L Shape Motor Bracket holding a JGB37-520 DC gear motor

Fix the JGB37-520 DC gear motor to your chassis using the L-shape bracket. The bracket fits 25-37mm diameter gear motors and keeps the shaft aligned.

Solder or crimp wires to the motor terminals. If your motor came with a connector, you can use female jumper wires to plug into the L298N screw terminals. Keep the wires short to reduce voltage drop.

Tip: Label the motor wires as A and B so you can identify them later.

DC Gear Motor Black L Shape Motor Bracket holding a JGB37-520 DC gear motor

Step 2: Wire the L298N driver to the motor and power

L298N Motor Driver Module Dual H-Bridge 3A connected to a JGB37-520 DC gear motor

Connect the motor to the L298N output terminals. Then connect the battery to the 12V and GND terminals on the driver.

  • Motor A: OUT1 and OUT2
  • Motor B: OUT3 and OUT4 (if using a second motor)
  • Battery positive: 12V terminal
  • Battery negative: GND terminal

The L298N has an onboard 5V regulator. If your motor supply is between 7V and 12V, you can use the 5V terminal to power your Arduino. If your supply is above 12V, remove the jumper and power the Arduino separately.

Important: Never power the motor from the Arduino 5V pin. The current draw will damage the board.

L298N Motor Driver Module Dual H-Bridge 3A connected to a JGB37-520 DC gear motor

Step 3: Connect the L298N to Arduino

Use jumper wires to connect the L298N control pins to the Arduino. Here is a common wiring plan:

L298N PinArduino Pin
ENA9 (PWM)
IN18
IN27
ENB10 (PWM)
IN36
IN45

ENA and ENB control speed using PWM. IN1 and IN2 set direction for motor A. IN3 and IN4 set direction for motor B.

Also connect the L298N GND to the Arduino GND. This common ground is required for the control signals to work.

Step 4: Upload the Arduino code

This simple sketch runs the motor forward, stops, then reverses. Adjust the speed value (0-255) to suit your project.

// JGB37-520 DC gear motor test with L298N
const int enA = 9;
const int in1 = 8;
const int in2 = 7;

void setup() {
 pinMode(enA, OUTPUT);
 pinMode(in1, OUTPUT);
 pinMode(in2, OUTPUT);
 Serial.begin(9600);
}

void loop() {
 // Forward at 200 speed
 digitalWrite(in1, HIGH);
 digitalWrite(in2, LOW);
 analogWrite(enA, 200);
 delay(2000);

 // Stop
 digitalWrite(in1, LOW);
 digitalWrite(in2, LOW);
 delay(1000);

 // Reverse at 150 speed
 digitalWrite(in1, LOW);
 digitalWrite(in2, HIGH);
 analogWrite(enA, 150);
 delay(2000);

 // Stop
 digitalWrite(in1, LOW);
 digitalWrite(in2, LOW);
 delay(1000);
}

Upload the code. The motor should run forward for two seconds, stop, then reverse. If it does not move, check your wiring and battery voltage.

Step 5: Test and adjust

Power up the system. If the motor spins in the wrong direction, swap the two motor wires at the L298N output. If it does not spin at all, measure the battery voltage with a multimeter. A drained battery is the most common cause.

For smooth low-speed operation, use a PWM value above 50. Below that, many DC motors stall. If you need very slow movement, consider a stepper motor instead.

If you are building a robot car, you may want to add a second motor. The L298N can drive two JGB37-520 motors independently.

Common mistakes to avoid

These are the problems that come up most often with the JGB37-520 DC gear motor and L298N.

  • No common ground: The Arduino and L298N must share a ground. Without it, the control signals have no reference.
  • Powering the motor from Arduino: The 5V pin cannot supply enough current. Always use a separate battery for the motor driver.
  • Wrong PWM pin: ENA and ENB must be connected to PWM-capable pins (marked with ~ on Arduino Uno).
  • Battery voltage too low: A 9V rectangular battery cannot supply the current a gear motor needs. Use a 6-cell AA pack or a 2S Li-ion pack.
  • Missing heat sink: The L298N gets hot under load. The module has a heat sink, but ensure airflow if running continuously.

Troubleshooting: motor does not spin

If the motor does not spin, work through these checks in order.

  1. Check battery voltage. A depleted battery is the most common cause. Measure with a multimeter.
  2. Check connections. Ensure the motor wires are tight in the screw terminals and the jumper wires are seated.
  3. Check the code. Confirm the pin numbers match your wiring. Use the Serial Monitor to print values if needed.
  4. Check the L298N enable pins. ENA and ENB must be HIGH or receiving PWM. If they are LOW, the motor will not move.
  5. Test the motor directly. Briefly connect the motor to a battery to confirm it works. If it does not, the motor may be faulty.

If the motor spins but is weak, increase the PWM value or use a higher battery voltage within the motor’s rating.

Where to get parts in Pakistan

College Road Electronics stocks the L298N driver, mounting brackets, and servo motors for robotics projects. The Motors, Drivers and Wheels category has options for students and hobbyists. Delivery is nationwide across Pakistan at a flat Rs. 350. Students can also get guidance for school, college, and university projects.

If you need a smaller motor for a lightweight build, consider an N20 micro gear motor or a 370 DC motor. These are also available from the same category.

Frequently asked questions

What voltage does the JGB37-520 DC gear motor need?

The JGB37-520 typically runs on 6V to 12V DC. Check the label on your specific motor for the exact rating. A 6-cell AA battery pack (9V) or a 2S Li-ion pack (7.4V) works well. Do not exceed the rated voltage or the motor will overheat.

Can I power the JGB37-520 directly from Arduino?

No. The Arduino 5V pin cannot supply the current a gear motor needs. You must use a motor driver like the L298N and a separate battery for the motor. The Arduino only sends control signals to the driver.

How do I reverse the direction of the JGB37-520 motor?

Swap the two motor wires at the L298N output terminals, or change the code so IN1 is LOW and IN2 is HIGH instead of the other way around. Both methods reverse the rotation.

Why does my motor only spin at high PWM values?

DC gear motors need a minimum voltage to overcome friction and start moving. Below a certain PWM value (often around 50 out of 255), the motor stalls. This is normal. Use a higher PWM value for reliable starting.

What is the difference between JGB37-520 and N20 micro gear motor?

The JGB37-520 is larger and delivers more torque, making it suitable for medium robot cars. The N20 micro gear motor is much smaller and lighter, ideal for tiny robots or mechanisms where space is tight. Choose based on your torque and size requirements.

Where can I buy the L298N driver in Pakistan?

College Road Electronics sells the L298N Motor Driver Module for Rs. 400. They deliver nationwide across Pakistan at a flat Rs. 350. You can order online from their website.

Leave a Reply

0
0
Your Cart
Your cart is emptyReturn to Shop