Created
March 14, 2014 17:09
-
-
Save ersatzavian/9552161 to your computer and use it in GitHub Desktop.
LED Breather
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
// Pulse the LED | |
// Adapted from http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ by Sean Voisen | |
function pulse_led(led) { | |
imp.wakeup(0.05, function() { | |
pulse_led(led); | |
}); | |
// Work out the next PWM level | |
local led_level = (math.exp(math.sin(hardware.millis()/2000.0*PI)) - 0.36787944) * 0.423529412; | |
led.write(led_level); | |
} | |
led_red <- hardware.pin1; | |
led_red.configure(PWM_OUT, 1.0/400.0, 0.0); | |
led_red.write(0); | |
pulse_led(led_red); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment