Skip to content

Instantly share code, notes, and snippets.

@pfn
Last active November 24, 2020 22:03
Show Gist options
  • Save pfn/68f82b06c9a3c3f9c13f657f0659cc5e to your computer and use it in GitHub Desktop.
Save pfn/68f82b06c9a3c3f9c13f657f0659cc5e to your computer and use it in GitHub Desktop.
void setup() {
Serial.begin(9600);
pinMode(11, OUTPUT);
analogReference(DEFAULT);
}
void loop() {
static int lastValue = 0;
int value = analogRead(A0) >> 3;
if (lastValue != value) {
Serial.println(value);
analogWrite(11, min(255, 128 + value));
lastValue = value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment