Skip to content

Instantly share code, notes, and snippets.

@wtshm
Last active January 26, 2017 05:33
Show Gist options
  • Save wtshm/a377583c5f100089e6f10db9bc53b6e1 to your computer and use it in GitHub Desktop.
Save wtshm/a377583c5f100089e6f10db9bc53b6e1 to your computer and use it in GitHub Desktop.
#define LED_PIN 9
void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
pulseLED();
// breatheLED();
}
void pulseLED() {
float val = 128.0 + 128 * sin((millis() / 1000.0) * PI);
analogWrite(LED_PIN, val);
}
void breatheLED() {
float val = (exp(sin(millis() / 2000.0 * PI)) - 0.36787944) * 108.0;
analogWrite(LED_PIN, val);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment