I want to control a servo and led with a remote , i have a 2 channel receiver ( one of an rc car) connected to UNO. The led works fine ,but the servo doesnt move although I checked the servo with the SWEEP code and it works fine
#include <Servo.h>
// Pin numbers
const int ledPin = 13;
const int onPin = 3;
const int offPin = 2;
int servoPin = 9;
const int servoMinAngle = 0;
const int servoMaxAngle = 180;
const int leftpin = 4;
const int rightpin = 5;
Servo myServo;
void setup() {
// Set LED pin as output
pinMode(ledPin, OUTPUT);
// Set input pins
pinMode(onPin, INPUT);
pinMode(offPin, INPUT);
pinMode(rightpin, INPUT);
pinMode( leftpin, INPUT);
}
void loop() {
// Check if pin 3 is high, turn on LED
if (digitalRead(onPin) == HIGH) {
digitalWrite(ledPin, HIGH);
}
// Check if pin 2 is high, turn off LED
if (digitalRead(offPin) == HIGH) {
digitalWrite(ledPin, LOW);
}
// Check if pin 4 is high, move servo to 0 degrees
if (digitalRead(leftpin) == HIGH) {
myServo.write
(servoMinAngle);
// You need to define or implement the moveServo function.
}
// Check if pin 5 is high, move servo to 180 degrees
if (digitalRead(rightpin) == HIGH) {
myServo.write (servoMaxAngle);
// You need to define or implement the moveServo function.
}
}
