Servo Motor

So I using a Kookye servo motor 180 degree rotation. I have it connected to a arduino uno, and I want it to rotate 180 degree through a signal from a PIR motion sensor that is connected to another arduino. 180 degree when the signal is ON, and back to 0 degree when the signal is OFF. I have both arduinos connected through a transmitter and a receiver. A 9v battery powers the arduino, ant a 6v battery powers the servo(with a common ground).
The problem is that the servo motor only rotates in counterclock direction till the point where it can’t rotate any more. I have opened the servo motor to see if any of the part inside is broken or not, but everything looks good. I out it back together and checked to see how it works, and it’s still rotates counterclock.

At the moment I’m not sure about sending it to a repair shop or buying another one. Any suggestions on what might be wrong, or if I do need another servo motor, and if I do need another servo motor, what kind/type do you guys recommend?

Thank you!.

Hi,

If the motor’s internals seem fine, is it possible you are not providing a proper control signal to the motor itself?

We assume this is a typical RC servomotor. Did you try connecting to one of your Arduinos and simply run the Sweep example? (See image below).

By default this example uses pin 9, so either modify the example before uploading or connect your servo’s control signal pin to pin 9. It makes the motor turn in both direction to full extension.

If the motor still moves only in one direction with the Sweep example, that would typically mean an issue with either its control chip or encoding system (unable to know its position) or driving circuit (typically a burnt half-bridge).
In either case, you’d need to send it back for replacement from wherever you bought it from.

Sincerely,

So I did tried the sweep example, it works 100% fine. A proper signal meaning the PIR sensor is not providing a 100% input?
Ok I’m going to attach a heat sensor instead of a PIR sensor, to see if that works.

So the heat sensor didn’t worked either, the servo again just rotated to counterclock direction.
Here’s the code for the first part, i.e the input part of this project.

[code]#define temp_pin 11
#define IR_transmitter_pin 9

void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(temp_pin, INPUT); // declare sensor as input
pinMode(IR_transmitter_pin, OUTPUT); // declare sensor as input
}

void loop() {
int temp_input;

temp_input = digitalRead(temp_pin);
digitalWrite(IR_transmitter_pin, temp_input);
digitalWrite(LED_BUILTIN, temp_input);
delay(100);

}

[/code]

And this is the servo part.

#include <Servo.h>

#define IR_receiver_pin 5

Servo servo_motor;  // create servo object

void setup() {
  pinMode(IR_receiver_pin, INPUT); // declare sensor as input
  servo_motor.attach(9);  // attaches the servo on pin 9 to the servo object
  servo_motor.write(0);   // resets the servo to 0 degrees
}

void loop() {
int IR_state;
//  int last_IR_state =-1;    use this only if necessary

IR_state = digitalRead(IR_receiver_pin);

if (IR_state == 1)  {
  servo_motor.write(180);   
} else {
  servo_motor.write(0);    
}

}

Tell me if something is not right here.
Thank you.

Hey,

Good to know your servomotor is working properly.

Well, it seems very likely your receiver is detecting the wrong thing and getting stuck in one direction.

The best for such systems is to test each module/section of the project individually to ensure proper functionality before integrating it all together (where issues become more difficult to figure out).

So, to test this, here’s what I would recommend:

  1. In your receiver, add some serial code to initialize the serial interface and output the value read by the digital read.
  2. Instead of using the IR transmitter board, connect the IR transmitter LED to a button instead (with proper circuitry to prevent burning it, such as resistors or voltage/current control, etc.).
    With that setup, try again your receiver board by itself, connecting it to your computer by USB and to the Arduino IDE serial monitor. Check if the serial output matches the state of your IR LED.

It is very possible that you are picking up noise instead of your signal, preventing proper working. You’ll most likely want to use a more complex (and error-correcting) protocol instead (kinda like what TC remotes do!). There is a lot of code already available for such noise resistance communications, so you may want to look into getting one of these for the receiver part, as they can make communication very reliable.

Sincerely,