this one is very interesting!
i also want to read a servomotor, i think reading requires an input and writing an output(?)
in my case a nephew of mine wants an automated blinker on his R/C truck for driving left and right
the steering itself is originated from the r/c controller/transmitter and servo (the servoGND and) SERVOsignal will go to an input of an arduino
there i want to read the signal as a value and this
int Servo::read() // return the value as degrees
{
return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180);
}
I did not dig into the library, but it looks like servo.read() takes no arguments, using a standard MIN/MAX (guessing: 1000us, 2000us but could be 450us, 2500us) and maps the current microseconds pulse width to 0/180 degrees. If you want to see the microseconds or degrees, try printing it when inside this library function.
No, you want to read the signal sent from the transmitter to the RC receiver. The Arduino will act as a wedge between the transmitted signal and the devices you wish to output that signal to. In your case, it seems you want to output the signal to both the steering servo and one of two led blinkers.
Connect the RC truck receiver channel 2 (or whatever channel the servo was connected to) to a digital pin on the Arduino.
Here's a sketch to get you started reading in the signal:
/*
use pulseIn() command to read the length of
the pulse on D9, with a timeout of 20000 mS
> EQUIPMENT: SPEKTRUM DX8 TX ; SPEKTRUM AR6210 RX
RX POWERED BY 5.1 V CASTLE CREATIONS BEC (NOT THAT IT REALLY SHOULD MATTER)
> TX SETTINGS:
DX8 TX, DSMX FASTFRAMERATE-- 2 CHANNEL SWITCH (GEAR, REVERSE)
IN HELI MODE, NO TRIMS OR ADJUSTMENTS APART FROM REVERSING GEAR CHANNEL
> RESULT:
GEAR LOW, (0): 1098-1112 uS
GEAR HIGH, (1): 1904-1916
TX OFF: 1098-1112 uS */
int ppm = 9;
int led = 13;
int servo_val; //use servo_val to hold the pulse length
void setup() {
Serial.begin(115200);
Serial.println("serialServoReadPulse\n");
delay(1000); // a sec to read sketch loaded on Arduino
pinMode(ppm, INPUT);
pinMode(led, OUTPUT);
}
void loop() {
servo_val = pulseIn(ppm, 20000);
/* check the pulse length to see if
it is above 1600 mS (neutral on mine, 1500 typical) */
if (servo_val > 1600) {
Serial.println(servo_val);
digitalWrite(led, HIGH);
} else {
Serial.println(servo_val);
digitalWrite(led, LOW);
}
/* just for readability. Don't use delay()
in real time RC signal processing */
delay(500);
}