        (recur))))
 
 
-(defn close-door! [hb floor-io]
+(defn close-door! [hb floor-btn]
   (hb/forward! hb)
-  (wait-till (closed? floor-io)
+  (wait-till (closed? floor-btn)
     (hb/stop! hb)))
 
 
-(defn open-door! [hb roof-io]
+(defn open-door! [hb roof-btn]
   (hb/reverse! hb)
-  (wait-till (closed? roof-io)
+  (wait-till (closed? roof-btn)
     (hb/stop! hb)))
 
 

        temp-ain  (ain 35)
        mtr-ctrl  (hb/hbridge [16 17 18] :header :P8)
        timer     (time-sm
                    (init-state! floor-io roof-io light-ain)
                    (partial close-door! hb roof-io)
                    (partial open-door! hb roof-io))]
    (loop [time-sm time-sm]
      (recur (trans-sm! timer (read! light-ain))))))


(defn play []
  (println "ready to initialize")
  (let [g (gpio :P8 11 :low)
        a (ain 33)]
    (setup-shutdown-hook!
      (fn [] (close! g)))
    (println "Pin settings" ((pinout-spec*) [:P8 11]))
    (println "initialized successfully")
    (doseq [_ (range 100)]
      (println "Writing :on")
      (write! g :on)
      (Thread/sleep 1000)
      (println "Writing :off")
      (write! g :off)
      (println "Reading ain:" (read! a))
      (Thread/sleep 1000))))





(defn init-state!
  [floor-btn roof-btn light-ain]
  (cond
    (closed? floor-btn) :night
    (closed? roof-btn) :day
    (> (read! light-ain) 0.35) :day
    :else :night))

