Created
October 26, 2010 05:47
-
-
Save paultag/646396 to your computer and use it in GitHub Desktop.
Throbber
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
/* | |
* "Throb" effect. | |
* | |
* Paul Tagliamonte, 2010. | |
* | |
* This is a re-take on the classic "pulse" ( otherwise | |
* known as the standby, throb, blob, mob or rob effect ) | |
* | |
* Yes, that was a joke. Lighten up, this is programming. | |
* | |
* This was re-done to look nicer by my very personal | |
* coding standards. Done with much love at 2:00 AM | |
* because I can't sleep. Oh well. | |
* | |
* This code is released under the Bacon license. | |
* If you like this code enough, consider sending me bacon. | |
* | |
* That or GPL-3+. | |
* | |
*/ | |
// Cycle <-- this is "static". | |
// +-----+ | |
// | | |
// |ON <-- this changes bunches | |
// +--+ | |
// | | |
// | OFF <-- ( cycle - ON ) | |
// | +--+ | |
// | | |
// +--+ +--+ +--+ | |
// | | | | | | | |
// | | | | | | ----> ( and so on ) | |
// | | | | | | | |
// | | | | | | | |
// | +--+ +--+ +-- | |
int ledPin = 13; // cute LED built into the Arduino | |
int cycle = 30; // miliseconds. | |
int on = 20; // " | |
int bottom = 5; // this is the flicker avoider | |
// if we drop to 0, then it blanks out | |
// and has a piss-poor blink. I know | |
// we can put a cap between it, but it's | |
// just too much work. I'll code around it | |
// for now. If you don't like this, then | |
// set it to 0. Much love. | |
int adder = 1; // this gets flipped around later. | |
void setup() { | |
pinMode(ledPin, OUTPUT); // Vomit down this hole. | |
} | |
void loop() { // damn kids don't have an int main() { ... } | |
on = on + adder; // on cycle length | |
if ( on >= cycle || on <= bottom ) | |
adder = -adder; // if we're at the border, invert the adder | |
// | |
// Here's where the babymaking goes on | |
// | |
digitalWrite(ledPin, HIGH); // BRIGHT! | |
delay(on); // Wait for it! | |
digitalWrite(ledPin, LOW); // Darker then my coffee | |
delay(cycle - on); // Wait for it! | |
// | |
// Lather, rinse and repeat. | |
// | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment