LE: I'm almost certain that the problem is noise from the DC motor. I tried with a spare motor laying around and it had no problem, even if it had no capacitor on it's leads. So I tried adding all kinds of capacitors on the present motors, no improvement. I guess I'll search for another wireless solution.

So I want to build a remote controlled car using a cheap 433MhZ receiver and transmitter. I am using this motor driver. I send the values from the joystick to the receiver and based on that I control the motor's direction. The problem is that when I use PWM (or digitalWrite) the receive data code completely freezes (my guess is receiver fault). Other code in the program works so the only problem is in the communication department. I don't think it's a software problem because when I pull out the PWM pin to the motor driver, code starts running again. I tried with another driver (TB6612FNG), I tried another receiver, I tried another library for 433MhZ (VirtualWire), I tried using SoftPWM library, I tried using a 220 Ohm resistor in series with the PWM signal, nothing works. I put a LED on the PWM pin, no problem.

I'm using two 3.7V lithium batteries as power. The receiver gets 5V directly from arduino. I also tried using a voltage divider to power the receiver directly from the batteries.

Here's the code, it's the last version that uses RCSwitch library for comms, I send the values from the joystick as 8 byte, read the respective bits and based on them I control the motors. Now it has a workaround that if the receive code is not in use, after a period it stops the motors, gets the data, starts motors again, but this is not acceptable.


RCSwitch mySwitch = RCSwitch();

bool up1, down1;
byte recData;

int AIN1 = 10;
int AIN2 = 9;
int BIN1 = 5;
int BIN2 = 6;
unsigned long resetTime;
unsigned long period = 3000;

void setup() {
  mySwitch.enableReceive(0);  // Receiver on interrupt 0 => that is pin #2
    pinMode(AIN1, OUTPUT);
    pinMode(BIN1, OUTPUT);
    pinMode(AIN2, OUTPUT);
    pinMode(BIN2, OUTPUT);

void loop() {
  if (mySwitch.available()) {
    recData = mySwitch.getReceivedValue();
    Serial.println("Received ");
    resetTime = 0;
  if (resetTime > period) 
      recData = 0;
   up1 = bitRead(recData, 7);
   down1 = bitRead(recData, 6);
  Serial.print("  ");
  Serial.print("  ");
  Serial.print("  ");
  if (up1) {
      analogWrite(AIN1, 255);
      analogWrite(AIN2, 0);
      analogWrite(BIN1, 255);
      analogWrite(BIN2, 0);
    else if (down1) {
      analogWrite(AIN1, 0);
      analogWrite(AIN2, 255);
      analogWrite(BIN1, 0);
      analogWrite(BIN2, 255);
    else {
      analogWrite(AIN1, 0);
      analogWrite(AIN2, 0);
      analogWrite(BIN1, 0);
      analogWrite(BIN2, 0);      

  • perhaps the motor is generating too much RF interference – jsotola Aug 13 at 0:31
  • Yes, I suspected that too. The RC car is a cheap chinese, but the motors have some capacitors on them. Anyway I ordered some nRF24L01 hoping that 2.4GhZ and spi communication will solve the problem. – sundaysfantasy Aug 13 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.