Yesterday a PWM reader code that I have had for a few days stopped working and started giving unusual outputs in the serial monitor. Normally the signal for when my RC remote is in the middle position it reads around 1500 now, no matter what, the code gives me between 4000 and 9000 in the serial monitor. I am fairly new to Arduino, but I think it may be a bug with the serial monitor or something else. I even tried changing the baud and what pins I was using but it still didn't work. If anyone knows anything about this problem or how to fix it, I would really appreciate that.
Here is my code:
// controller pins
const int CH_2_PIN = 11;
void setup() {
Serial.begin(9600);
}
void loop() {
int ch_2 = pulseIn(CH_2_PIN, HIGH,25000);
Serial.println(ch_2);
delay(5);
}
Here is what it keeps reading in the monitor:
10096
1330
1101
444
0
8517
8618
8659
8688
8664
9474
8887
8244
7669
7185
6832
6553
6502
6484
6581
6940
7297
7852
8490
9435
10071
1346
1039
512
0
8539
8590
8709
8671
8671
9511
8914
8296
7756
7203
6801
6608
6485