add an example
This commit is contained in:
parent
5b9eb6b429
commit
0beb92d299
5
_oasis
5
_oasis
|
@ -13,3 +13,8 @@ Library "WiringPi"
|
||||||
CSources: WiringPi_stubs.c
|
CSources: WiringPi_stubs.c
|
||||||
CCLib: -lwiringPi
|
CCLib: -lwiringPi
|
||||||
|
|
||||||
|
Executable "wpi-button-example"
|
||||||
|
Path: examples/
|
||||||
|
BuildTools: ocamlbuild
|
||||||
|
MainIs: button.ml
|
||||||
|
BuildDepends: WiringPi,unix
|
|
@ -0,0 +1,22 @@
|
||||||
|
open Gpio3
|
||||||
|
|
||||||
|
(* Set up the pins the following way: *)
|
||||||
|
(* pin 3 (pull-up) -> btn -> resistor -> gnd *)
|
||||||
|
|
||||||
|
let setup () =
|
||||||
|
Gpio3.setup ();
|
||||||
|
pin_mode GPIO3 IN;
|
||||||
|
pull_up_dn_control GPIO3 UP
|
||||||
|
|
||||||
|
let rec loop () =
|
||||||
|
(match digital_read GPIO3 with
|
||||||
|
| LOW -> print_endline "-- LOW"
|
||||||
|
| HIGH -> print_endline "++ HIGH");
|
||||||
|
Unix.sleepf 0.5;
|
||||||
|
loop ()
|
||||||
|
|
||||||
|
|
||||||
|
let _ =
|
||||||
|
setup ();
|
||||||
|
loop ();
|
||||||
|
|
Loading…
Reference in New Issue