Skip to content

Instantly share code, notes, and snippets.

@omerk
Created October 31, 2013 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omerk/7254847 to your computer and use it in GitHub Desktop.
Save omerk/7254847 to your computer and use it in GitHub Desktop.
-module(ale_halloween).
-export([start/0]).
init() ->
application:start(gproc),
gpio:start_link({4, output}),
gpio:start_link({17, output}),
gpio:start_link({18, output}),
gpio:start_link({27, output}),
gpio:start_link({22, output}),
gpio:start_link({23, output}).
set(Val) ->
gpio:write(4, lists:nth(1, Val)),
gpio:write(17, lists:nth(2, Val)),
gpio:write(18, lists:nth(3, Val)),
gpio:write(27, lists:nth(4, Val)),
gpio:write(22, lists:nth(5, Val)),
gpio:write(23, lists:nth(6, Val)).
blink() ->
set([1,1,1,1,1,1]),
io:format("LED on~n"),
timer:sleep(1000),
set([0,0,0,0,0,0]),
io:format("LED off~n"),
timer:sleep(1000).
play() ->
set([rb(), rb(), rb(), rb(), rb(), rb()]),
timer:sleep(500),
play().
rb() ->
random:uniform(2) - 1.
start() ->
init(),
io:format("blink test~n"),
blink(),
io:format("start pattern~n"),
play().
@omerk
Copy link
Author

omerk commented Oct 31, 2013

gpio module is part of the Erlang/ALE framework, more information at: http://opensource.erlang-solutions.com/erlang_ale/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment