hArduino-0.6: Control your Arduino board from Haskell.

Safe HaskellNone




Demonstrates pulseIn_hostTiming and pulseOut_hostTiming functions, sending and receiving pulses to/from the board.


Detecting pulses

pulseInDemo :: IO ()Source

Computes the amount of time a push-button is connected to input pin 2 on the Arduino. We will wait for at most 5 seconds, as a further demonstration of the time-out facility. Note that the timing is done on the host side, so this measurement is inherently inaccurate.

The wiring is straightforward: Simply put a push-button between digital input 2 and +5V, guarded by a 10K resistor:

Sending pulses

pulseOutDemo :: IO ()Source

Send pulses on a led as requested by the user. Note that the timing is computed on the host side, thus the duration of the pulse is subject to some error due to the Firmata communication overhead.

Wiring: Simply a led on pin 13: