-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblink.hs
34 lines (26 loc) · 809 Bytes
/
blink.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{-# LANGUAGE ForeignFunctionInterface #-}
import Foreign
import Foreign.C.Types
import Control.Concurrent
foreign import ccall safe "prototypes.h"
c_wiringPiSetup :: IO Int
foreign import ccall safe "prototypes.h"
c_pinMode :: Int -> Int -> IO ()
foreign import ccall safe "prototypes.h"
c_digitalWrite :: Int -> Int -> IO ()
main :: IO ()
main = do
pin <- c_wiringPiSetup
case pin of
-1 -> error "Pins are not available"
0 -> do
c_pinMode 0 1
c_digitalWrite 0 1
n <- getLine
c_digitalWrite 0 0
n <- getLine
c_digitalWrite 0 1
n <- getLine
c_digitalWrite 0 0
n <- getLine
c_digitalWrite 0 1