My servo is messing with my IR signal

Hi there,

My goal:
I'm using my Uno with a infrared sensor & remote to control a solenoid valve & a servo. I'm making a vinegar & baking soda powered car for a family competition (weird I know). Anyway, the servo releases the baking soda & I'll open the solenoid when the PSI in the bottle gets to a level. The PSI gauge is a manual/visual thing that I'm not going to code or anything fancy.

Where I'm at:
It all works and I'm pretty happy with my little project. There is one annoying problem that I think is down to my terrible copy/paste job with Arduino code.

Problem:
The servo ticks & hums all the time, which isn't really a problem, except that it seems to scramble my IR codes from the remote. I get all sorts of weird numbers from the remote which makes it hard to operate the solenoid. It eventually gets the correct signal and opens the solenoid. If I pull the digital pin from the servo, it stops ticking and the signal become stable again.

Help:
Would someone be able to look at my code and see what might be the problem. Any help or code adjustment I might try would be greatly appreciated.

Materials:
Uno
HXT900 Servo
12v Solenoid

#include <Servo.h>
#include <IRremote.h>

unsigned long Value1 = 0xD3F; // where XXXXXXXX is another button on your remote
unsigned long Value2 = 0x47F; // where XXXXXXXX is on our your remote's values. We will call this Value 1
unsigned long Value3 = 0xE13DDA28; // where XXXXXXXX is another button on your remote
unsigned long Value4 = 0xAD586662; // where XXXXXXXX is another button on your remote

int RECV_PIN = 3;
int solPin = 5;
IRrecv irrecv(RECV_PIN);
decode_results results;
 
Servo servo1;







void setup() {            

Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
    pinMode(solPin, OUTPUT);

servo1.attach(13); // attach servo to digital pin 9

}



// the loop routine runs over and over again forever:
void loop() {

if(results.value == Value3) {
    unsigned int value = results.value;
    digitalWrite(solPin, HIGH);   
    delay(100);   
}


if(results.value == Value4) {
    unsigned int value = results.value;
    digitalWrite(solPin, LOW);   
    delay(100);   
}



if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
     }

if(results.value == Value1) {
servo1.write(176);
}

if(results.value == Value2) {
servo1.write(3);
}

}

How is the servo powered ? Direct from the Arduino (wrong answer) or from an external source (right answer) ?

Just out of interest why do you keep creating new variables named value that you never use ?

Hi, can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

We need to see how you have connected everything, how are you powering the servo and solenoid.
The arduino cannot provide enough power for a servo, it needs to have a supply capable of driving the servo.

Tom..... :slight_smile:
Hi UKHeliBob, missed it by that much, lol..

Thanks Tom & UKHeliBob. I'm totally powering the servo from the Arduino! I'll change this and let you know how I get on.

I've got 12v powering the solenoid. I'm sure I can work out how to lower the voltage and run the servo too.

I appreciate you taking the time to respond guys!

DWS

It's alive!!!!

Thanks for the advice. Putting the servo on it's own power supply fixed both the jittering and the weird IR signals.

Thanks again to both of you.