Hello all,
First timer here, and I've run into an issue with the 433MHz RF module I'm using as a remote control (Four-channel 433 MHz radio module + remote control Botland - Robotic Shop).
I'm making a basic robot, and I have everything set up, but once the robot gets a command to start moving, the receiver doesn't pickup inputs from the remote control unless they're practically next to each other. Control, check. Remote, not so much.... I confirmed this both by the robot's behavior, and by checking the Serial Monitor.
I'm using two DAGU robot DG01D motors within a Magician Chassis v2.
From what I've read on some similar topics here, interference from the DC motors might be the cause. If that's the case, how would you suggest I fix it?
Do I...
- Get a new / better RF module?
- Get different (?better-shielded?) motors?
- Setup the wiring to reduce RF interference? (I read a bit about LC circuits...)
- OR something else that I don't know about?
Any help would be much appreciated.
All the best,
Josh
P.S. Other potentially relevant details:
- I'm using the Leonardo board
- I'm using 6xAA to power the system through the 2.1mm plug, and I see ~12V running through circuit with my multimeter
- I'm using the SparkFun Motor Driver - Dual TB6612FNG to transform my outputs to the motor controls
- I'm using 2 capacitors: 1000uF/25V and 100uF/16V
Setup diagram from the inspiration of the project, Simon Monk's Hacking Electronics. (Circuit diagram in the next post due to image limits.)
Code, modified from Simon Monk's repo to suit my slightly different wiring due to headers being on the reverse side as in the tutorial. (hacking_electronics/rover at master · simonmonk/hacking_electronics · GitHub)
// rover
// Arduino Uno or Leonardo
int fullPower = 192;
int slowPower = 128;
int PWMApin = 3;
int AIN1pin = 5;
int AIN2pin = 4;
int PWMBpin = 9;
int BIN1pin = 7;
int BIN2pin = 8;
int remotePins[] = {10, 11, 12, 13};
int lastPinStates[] = {0, 0, 0, 0};
void setup()
{
pinMode(PWMApin, OUTPUT);
pinMode(AIN1pin, OUTPUT);
pinMode(AIN2pin, OUTPUT);
pinMode(PWMBpin, OUTPUT);
pinMode(BIN1pin, OUTPUT);
pinMode(BIN2pin, OUTPUT);
for (int i = 0; i < 4; i++)
{
pinMode(remotePins[i], INPUT);
}
Serial.begin(9600);
}
void loop()
{
Serial.print("Pressed :");
Serial.print(digitalRead(remotePins[0]));
Serial.print(digitalRead(remotePins[1]));
Serial.print(digitalRead(remotePins[2]));
Serial.print(digitalRead(remotePins[3]));
Serial.print(" Pin States: ");
Serial.print(lastPinStates[0]);
Serial.print(lastPinStates[1]);
Serial.print(lastPinStates[2]);
Serial.println(lastPinStates[3]);
int keyPressed = getKeyPress();
Serial.print(" Pin States: ");
Serial.print(lastPinStates[0]);
Serial.print(lastPinStates[1]);
Serial.print(lastPinStates[2]);
Serial.print(lastPinStates[3]);
Serial.print(" Key Press: ");
Serial.println(keyPressed);
if (keyPressed == 1)
{
stopMotors();
Serial.println("Stopping Motors");
}
else if (keyPressed == 3)
{
turnLeft();
Serial.println("Turning Left");
}
else if (keyPressed == 0)
{
turnRight();
Serial.println("Turning Right");
}
else if (keyPressed == 2)
{
forward();
Serial.println("CHARGE!");
}
delay(500);
}
void stopMotors()
{
digitalWrite(AIN1pin, LOW);
digitalWrite(AIN2pin, LOW);
analogWrite(PWMApin, 0);
digitalWrite(BIN1pin, LOW);
digitalWrite(BIN2pin, LOW);
analogWrite(PWMBpin, 0);
}
void turnLeft()
{
digitalWrite(AIN1pin, HIGH);
digitalWrite(AIN2pin, LOW);
analogWrite(PWMApin, slowPower);
digitalWrite(BIN1pin, LOW);
digitalWrite(BIN2pin, HIGH);
analogWrite(PWMBpin, slowPower);
}
void turnRight()
{
digitalWrite(AIN1pin, LOW);
digitalWrite(AIN2pin, HIGH);
analogWrite(PWMApin, slowPower);
digitalWrite(BIN1pin, HIGH);
digitalWrite(BIN2pin, LOW);
analogWrite(PWMBpin, slowPower);
}
void forward()
{
digitalWrite(AIN1pin, LOW);
digitalWrite(AIN2pin, HIGH);
analogWrite(PWMApin, fullPower);
digitalWrite(BIN1pin, LOW);
digitalWrite(BIN2pin, HIGH);
analogWrite(PWMBpin, fullPower);
}
int getKeyPress()
{
int result = -1;
for (int i = 0; i < 4; i++)
{
int remoteInput = digitalRead(remotePins[i]);
if (remoteInput != lastPinStates[i] and lastPinStates[i] == 0)
{
result = i;
}
lastPinStates[i] = remoteInput;
}
return result;
}


