arduino-copilot-1.0.0: examples/button/demo.hs
{-# LANGUAGE RebindableSyntax #-}
import Copilot.Arduino.Uno
longer_and_longer :: Stream Int16
longer_and_longer = counter true $ counter true false `mod` 64 == 0
counter :: Stream Bool -> Stream Bool -> Stream Int16
counter inc reset = cnt
where
cnt = if reset
then 0
else if inc
then z + 1
else z
z = [0] ++ cnt
main :: IO ()
main = arduino $ do
buttonpressed <- readfrom' pin12 [False, False, False, True, True]
led =: buttonpressed || blinking
delay =: longer_and_longer * 2