       (safe-int)
       (* (/ 1 1800.0)))))
 
+(defrecord MockAIN [pin]
+  ReadablePin
+  (read! [this]
+    @(:value this)))
+
+(defn set-mock-val!
+  [mock-ain new-value]
+  (reset! (:value mock-ain) value)
+  mock-ain)
+
+(defn mock-ain [pin]
+  (assoc (MockAIN. pin) :value (atom 0)))
+
 (defn ain [pin]
-  (AIN. pin))
+  (if *mock?*
+    (mock-ain pin)
+    (AIN. pin)))
+
 
 (defn toggle!
   [pin]

       (str "/sys/class/gpio/gpio" (get-gpio-n header pin) "/value")))))


(defn gpio [header pin direction]
  {:pre [(integer? pin) ; should make sure valid pin
         (#{:P8 :P9} header)
         (#{:in :out :high :low} direction)]}
  (let [g (GPIO. header pin direction)]
    (init! g)
    g))


(defn on? [gp]

  (:require [clojure.java.io :as io]
            [clojure.tools.trace :as tr]
            [strange-coop.util :as util :refer :all]))

(def ^:dynamic *mock?* false)


(defn read-pinout-spec [pinout-fn]
