Created
October 8, 2014 18:54
-
-
Save halldorel/b7e7de0d1f2dea986845 to your computer and use it in GitHub Desktop.
Arduino - LED blinker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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