Skip to content

Instantly share code, notes, and snippets.

@pfn
Last active Nov 24, 2020
Embed
What would you like to do?
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