Greetings,
First time poster here. I am troubleshooting an issue with my RC submarine ballast control system. I have an Arduino Nano (classic, official) connected to an RC receiver and a DC motor drive module (Drok L298 Dual H Bridge). The motor driver is powered directly by a 12 volt battery.
The problem is that whenever I command surface (D3 --> LOW, D4 --> HIGH), the serial monitor stops outputting. The device keeps working properly with motor responding to RC inputs, but I can no longer see things print to the serial monitor. Commanding dive with the motor running the other direction works with no issue.
Troubleshooting I have tried already:
- Increase serial communication rate (error persists)
- Use the other motor port (error persists)
- Increase delay between loops (error persists)
- Use a USB cable with the red wire cut (error persists)
- Disconnect motor from motor driver (serial monitor fixed)
- Disconnect data pins from motor driver (serial monitor fixed)
My hypothesis is that the motor is causing interference the serial interface. Please reply if you have a question or suggestion. Thanks!
int RCValue;
#define RCPin 2
int motor1pin1 = 3; // White wire, Goes to IN1
int motor1pin2 = 4; // Yellow wire, Goes to IN2
int motor2pin1 = 5; // Green wire, Goes to IN3
int motor2pin2 = 6; // Blue wire, Goes to IN4
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// Pump Motor & LED
pinMode(motor1pin1, OUTPUT); // Controls IN1
pinMode(motor1pin2, OUTPUT); // Controls IN2
pinMode(motor2pin1, OUTPUT); // Controls IN3
pinMode(motor2pin2, OUTPUT); // Controls IN4
}
void loop() {
// put your main code here, to run repeatedly:
delay(100);
// RC Input
RCValue = pulseIn(RCPin, HIGH); // Read RC Value
Serial.println(RCValue);
if (RCValue > 1700){
Serial.println("Diving");
digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, LOW);
} else if (RCValue > 1300){
Serial.println("Neutral");
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, LOW);
} else {
Serial.println("Surfacing");
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, HIGH);
}
}