Skip to content

Instantly share code, notes, and snippets.

@pleasehelpme798
Created May 1, 2023 00:49
Show Gist options
  • Save pleasehelpme798/eb4696b88ea8a3f7d6859907b93206d6 to your computer and use it in GitHub Desktop.
Save pleasehelpme798/eb4696b88ea8a3f7d6859907b93206d6 to your computer and use it in GitHub Desktop.
int pin = 9;
int value;
float xn1= 0;
float yn1 = 0;
int k = 0;
void setup (){
Serial.begin(9600);
pinMode(pin, INPUT);
}
void loop (){
value = pulseIn(pin, HIGH); //read pwm output from remote control receiver
float t = micros () / 1.0e6;
float xn = value;
float yn = 0.969*yn1 + 0.0155*xn + 0.0155*xn1; //compute filtered signal
delay(1);
xn1 = xn;
yn1 = yn;
if (k % 3 == 0) {
Serial.print(xn);
Serial.print(",");
Serial.println(yn);
}
k = k+1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment