Skip to content

Instantly share code, notes, and snippets.

@halldorel
Created October 8, 2014 18:54
Show Gist options
  • Save halldorel/b7e7de0d1f2dea986845 to your computer and use it in GitHub Desktop.
Save halldorel/b7e7de0d1f2dea986845 to your computer and use it in GitHub Desktop.
Arduino - LED blinker
const int PIN = 7;
void setup()
{
pinMode(PIN, OUTPUT);
digitalWrite(PIN, LOW);
}
const int MAX = 400;
const int MIN = 5;
int index = 0;
float delayNow = 0;
void loop()
{
delayNow = MIN + MAX * (1 + sin(index/16.0 * 3.1415))/2;
index = (index + 1) % 32;
digitalWrite(PIN, HIGH);
delay(delayNow);
digitalWrite(PIN, LOW);
delay(delayNow);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment