Skip to content

Instantly share code, notes, and snippets.

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/27a4b1290a8f2c235e8dfa794a36f35e to your computer and use it in GitHub Desktop.
Save ulrichzwingli/27a4b1290a8f2c235e8dfa794a36f35e to your computer and use it in GitHub Desktop.
Potentiometer dimming LED
int analog_range;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
analog_range = analogRead(A0);
if (analog_range<=512) {
digitalWrite(8, HIGH);
digitalWrite(13, LOW);
}
else
{
brightness = brightness + fade;
if (brightness == 0 || brightness ==255)
{
fade = -fade;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment