Last active
October 5, 2021 19:27
-
-
Save billykwok/458a5ce224f7c79d94709eed662dc37f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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