Skip to content

Instantly share code, notes, and snippets.

@extrasleepy
Created August 25, 2025 03:46
Show Gist options
  • Select an option

  • Save extrasleepy/75b8f4b4e427d7a47a3b23a604edeac8 to your computer and use it in GitHub Desktop.

Select an option

Save extrasleepy/75b8f4b4e427d7a47a3b23a604edeac8 to your computer and use it in GitHub Desktop.
// Define pins for the LEDs
#define LED_PIN0 0
#define LED_PIN1 1
void setup() {
pinMode(LED_PIN0, OUTPUT);
pinMode(LED_PIN1, OUTPUT);
}
void loop() {
fadeInOut(LED_PIN0);
fadeInOut(LED_PIN1);
}
void fadeInOut(uint8_t pin) {
for (int brightness = 0; brightness <= 254; brightness += 2) {
analogWrite(pin, brightness);
delay(30);
}
for (int brightness = 254; brightness >= 0; brightness -= 2) {
analogWrite(pin, brightness);
delay(30);
}
// Ensure LED is completely off at the end
analogWrite(pin, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment