Skip to content

Instantly share code, notes, and snippets.

@moomdate
Created April 22, 2019 02:57
Show Gist options
  • Select an option

  • Save moomdate/737c686ae200e3cc21358e3c2f99822f to your computer and use it in GitHub Desktop.

Select an option

Save moomdate/737c686ae200e3cc21358e3c2f99822f to your computer and use it in GitHub Desktop.
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(A0, INPUT);
}
float u, y;
int p = 0;
void loop() {
u = (float)analogRead(0) * 5;
u = (u / 1024) * 3.059;
y = 0.945 * y + 0.05498 * u;
// p = y * 100 / 4.19;
p = (y - 2.75) * 100.0 / (4.19 - 2.75);
Serial.print(p);
Serial.print("\t");
Serial.print(y);
Serial.println();
delay(350);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment