Skip to content

Instantly share code, notes, and snippets.

@ulrichzwingli
Created September 25, 2017 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ulrichzwingli/9dc2ecf68ec2af4846767bed15ed9bee to your computer and use it in GitHub Desktop.
Save ulrichzwingli/9dc2ecf68ec2af4846767bed15ed9bee to your computer and use it in GitHub Desktop.
code to dim LED as i change the resistance of the potentiometer
void setup() {
Serial.begin(9600);
pinMode(11, OUTPUT);
}
void loop() {
int state = analogRead(pin);
brightness = state*(255/1023);
Serial.println(state);
Serial.println(brightness);
analogWrite(11, brightness);
delay(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment