Created
October 31, 2013 18:47
-
-
Save omerk/7254847 to your computer and use it in GitHub Desktop.
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
-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(). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gpio
module is part of the Erlang/ALE framework, more information at: http://opensource.erlang-solutions.com/erlang_ale/