Skip to content

Instantly share code, notes, and snippets.

@camateg
Last active September 28, 2021 18:36
Show Gist options
  • Select an option

  • Save camateg/8c1f26fe007a192b01d1d3e6e447b85f to your computer and use it in GitHub Desktop.

Select an option

Save camateg/8c1f26fe007a192b01d1d3e6e447b85f to your computer and use it in GitHub Desktop.
#define LEDPWM 3
#define POT A1
void setup() {
pinMode(LEDPWM, OUTPUT);
pinMode(POT, INPUT);
Serial.begin(9600);
}
void loop() {
int val;
val = analogRead(POT);
Serial.print(int((val / 904.0) * 100));
Serial.println("%");
analogWrite(LEDPWM, val / 4);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment