So I've successfully been able to program LED flashing at various intervals and all is well with the world.
BUT now I am trying to read the PWM signal from a 3 position switch on my Futaba T8FG transmitter and I am getting weird numbers. From what I have seen this should be a very simple routine using PulseIn (might move to interrupts later but for now I can't even get PulseIn to work).
I have the signal wire ONLY from my Receiver plugged into digital pin 7. The power for the receiver is being supplied by a battery pack. The Arduino is getting power from the PC through the USB cable.
Here is the code:
byte PWM_PIN = 7;
int pwm_value;
void setup() {
pinMode(PWM_PIN, INPUT);
Serial.begin(115200);
}
void loop() {
pwm_value = pulseIn(PWM_PIN, HIGH);
Serial.println(pwm_value);
}
Here is the data being output depending on the position of the switch:
To me the data appears all over the place and un-usable.
I know it is reading SOMETHING because when I remove the pin out of 7 it goes to all zeros.
Any ideas? Spent a few hours on this and am a little ticked off.
Thanks.