diff --git a/src/clodiuno/firmata.clj b/src/clodiuno/firmata.clj index 3c1bdf6..9599391 100644 --- a/src/clodiuno/firmata.clj +++ b/src/clodiuno/firmata.clj @@ -75,7 +75,7 @@ (.write out 1))) (if (= type :digital) (do - (.write out (bit-or REPORT-DIGITAL pin)) + (.write out (bit-or REPORT-DIGITAL (if (< pin 8) 0 1))) (.write out 1))) (.flush out))) @@ -87,8 +87,8 @@ (.write out 0))) (if (= type :digital) (do - (.write out (bit-or REPORT-DIGITAL pin)) - (.write out 0))) + (.write out (bit-or REPORT-DIGITAL (if (< pin 8) 0 1))) + (.write out 0))) (.flush out))) (defmethod pin-mode :firmata [conn pin mode] @@ -122,6 +122,9 @@ (.write (byte-array (to-byte cmd state))) (.flush)))) +(defmethod digital-read :firmata [conn pin] + ((:digital-in-state @conn) pin)) + (defmethod analog-read :firmata [conn pin] ((:analog-in-state @conn) pin))