How to reduce noise from motor

Hello! I'm trying to control a DC motor using an IR remote. The program works perfectly when the motor is turned off, however the IR receiver doesn't seem to respond whenever the motor is turned on. I understand this to be related to noise being created by the motor. I know there's a way to reduce noise using capacitors but I'm not sure how to insert them into the circuit, please help!!!

here is my code:

#include <IRremote.h> //Make sure to install the library
int IRpin=3;
IRrecv IR(IRpin);
decode_results cmd;
String myCom;

int motorPin = 5;

void setup(){
pinMode(motorPin, OUTPUT);

void loop() {
  while (IR.decode(&cmd)==0){ 


analogWrite(motorPin, 255);

switch (cmd.value){
  //up arrow: motor runs
  case 0xCC3359A6:
    myCom = "up";
    digitalWrite(motorPin, HIGH);
  //down arrow: motor stops
  case 0xCC33D926:
    myCom = "down";
    digitalWrite(motorPin, LOW);


Here is the circuit diagram:
circuit (1)

Note: to control the motor I'm using a transistor and another battery for more power.

@federicoragno119, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with our project :wink: See About the Installation & Troubleshooting category.

If that transistor is a NPN bipolar junction transistor you are missing the base resistor to limit the base current.

You are missing the flyback diode, tool.

Put a 0.1uF cap across the motor and one from each motor power terminal to ground. See below (sorry for the crude drawing).

forum motor cap

Your schematic is a bit hard to read. Usually V+ is on top and ground is on the bottom.

A better schematic.

Not to ground, but to motor casing (which could then be grounded).

Thank you! Can't believe it actually worked. Don't want to take up too much of your time but could you please explain how this works if it isn't too complicated, I'm just starting out and learning the basics so I would really appreciate it :slight_smile: Federico.

Capacitors conduct AC but block DC. The brushes in the motor create AC noise that can get onto the power supply. The capacitors bypass higher frequency noise keeping the noise off the power supply.

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.