Skip to content

Instantly share code, notes, and snippets.

@billykwok
Last active October 5, 2021 19:27
Show Gist options
  • Save billykwok/458a5ce224f7c79d94709eed662dc37f to your computer and use it in GitHub Desktop.
Save billykwok/458a5ce224f7c79d94709eed662dc37f to your computer and use it in GitHub Desktop.
#define HB A0
#define PS A1
#define LED 9
void setup() {
Serial.begin(9600);
pinMode(LED, OUTPUT);
}
void loop() {
int ps = analogRead(PS);
if (ps <= 600) {
int hb = (analogRead(HB) - 400) * 2;
Serial.println(hb);
analogWrite(LED, min(hb, 255));
} else {
analogWrite(LED, 0);
}
delay(5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment