Hello everyone,
I’m experiencing an issue with my GoBuilda motors when using them with an Arduino. My transmitter is a Turbo Racing TP-TX2. The problem is that the motor starts producing sparks after running for about 30 to 40 seconds, even when the speed is constant. This issue also occurs at lower speeds.
I’ve tried calibrating the throttle and steering, but the problem persists. I would greatly appreciate any advice or suggestions from the community on how to resolve this, whether it’s through software adjustments or additional components.
Thank you so much in advance for any help or insights!
And this is my code:
// Motor 1 (Left) Pins
const int ENA = 5;
const int IN1 = 6;
const int IN2 = 7;
// Motor 2 (Right) Pins
const int IN3 = 8;
const int IN4 = 9;
const int ENB = 10;
// Receiver Pins
const int chThrottlePin = A2; // CH2 (Trigger)
const int chSteerPin = A3; // CH1 (Wheel)
// --- CALIBRATION SETTINGS ---
const int centerThrottle = 1385; // Your calibrated center for Throttle
const int centerSteer = 1500; // Standard center for Steering (Adjust if needed)
const int maxSpeed = 20; // Speed limit (20%)
void setup() {
pinMode(ENA, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT); pinMode(ENB, OUTPUT);
pinMode(chThrottlePin, INPUT);
pinMode(chSteerPin, INPUT);
Serial.begin(9600);
}
void loop() {
// 1. Read Signals
int rawThrottle = pulseIn(chThrottlePin, HIGH);
int rawSteer = pulseIn(chSteerPin, HIGH);
// Safety: If receiver disconnected, stop
if (rawThrottle < 500 || rawSteer < 500) {
stopMotors();
return;
}
// 2. Map Throttle (Using your 1385 Center)
int throttle = 0;
if (rawThrottle >= centerThrottle) {
throttle = map(rawThrottle, centerThrottle, 2000, 0, maxSpeed);
} else {
throttle = map(rawThrottle, 1000, centerThrottle, -maxSpeed, 0);
}
// 3. Map Steering
// We use standard 1000-2000 mapping. If steering is inverted, swap -50 and 50.
int steering = map(rawSteer, 1000, 2000, -maxSpeed, maxSpeed);
// 4. Deadzones (Ignore small jitters)
if (abs(throttle) < 5) throttle = 0;
if (abs(steering) < 5) steering = 0;
// 5. MIXING (Arcade Drive)
int leftMotor = throttle + steering;
int rightMotor = throttle - steering;
// 6. Constrain (Keep speed within allowed limits)
leftMotor = constrain(leftMotor, -maxSpeed, maxSpeed);
rightMotor = constrain(rightMotor, -maxSpeed, maxSpeed);
// 7. Drive Motors
driveMotor(1, leftMotor);
driveMotor(2, rightMotor);
// Debugging
Serial.print("RawStr: "); Serial.print(rawSteer);
Serial.print(" | L: "); Serial.print(leftMotor);
Serial.print(" | R: "); Serial.println(rightMotor);
}
// --- Helper to Drive Specific Motor ---
void driveMotor(int motorID, int speed) {
int pinPWM, pinA, pinB;
// Select Pins
if (motorID == 1) { pinPWM = ENA; pinA = IN1; pinB = IN2; } // Left
else { pinPWM = ENB; pinA = IN3; pinB = IN4; } // Right
if (speed > 0) {
// Forward
digitalWrite(pinA, (motorID == 1) ? HIGH : LOW); // Motor 1 High/Low
digitalWrite(pinB, (motorID == 1) ? LOW : HIGH); // Motor 2 Low/High
analogWrite(pinPWM, speed);
}
else if (speed < 0) {
// Reverse
digitalWrite(pinA, (motorID == 1) ? LOW : HIGH);
digitalWrite(pinB, (motorID == 1) ? HIGH : LOW);
analogWrite(pinPWM, abs(speed));
}
else {
// Stop
digitalWrite(pinA, LOW);
digitalWrite(pinB, LOW);
analogWrite(pinPWM, 0);
}
}
void stopMotors() {
driveMotor(1, 0);
driveMotor(2, 0);
}

