Skip to content

Instantly share code, notes, and snippets.

@profburke
Created April 24, 2017 02:21
Show Gist options
  • Save profburke/2196c47430d28ade8f5c5eb7e801e421 to your computer and use it in GitHub Desktop.
Save profburke/2196c47430d28ade8f5c5eb7e801e421 to your computer and use it in GitHub Desktop.
-- make use of morse.lua to do morse code via
-- LEDs on an ESP8266
-- first, rough attempt
morse = dofile 'morse.lua'
DOTPIN = 2
DASHPIN = 1
_sleep = 10000
sleep = function() tmr.delay(_sleep) end
on = function(p) gpio.write(p, gpio.HIGH) end
off = function(p) gpio.write(p, gpio.LOW) end
leddot = function() on(DOTPIN); sleep(); off(DOTPIN) end
leddash = function() on(DASHPIN); sleep(); sleep(); sleep();
off(DASHPIN) end
morse.setDotGenerator(function() leddot() end)
morse.setDashGenerator(function() leddash() end)
morse.setBlankGenerator(function() sleep() end)
morse.setCleanupFunction(function() end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment