{"id":18259015,"url":"https://github.com/hanselmw/archytas","last_synced_at":"2026-04-27T20:32:26.216Z","repository":{"id":85476475,"uuid":"65104296","full_name":"hanselmw/archytas","owner":"hanselmw","description":"Firmata for Clojure","archived":false,"fork":false,"pushed_at":"2017-05-08T01:50:04.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-09T22:11:28.304Z","etag":null,"topics":["arduino","firmata","iot"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hanselmw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-06T22:16:38.000Z","updated_at":"2017-05-06T04:34:02.000Z","dependencies_parsed_at":"2023-04-14T08:31:35.525Z","dependency_job_id":null,"html_url":"https://github.com/hanselmw/archytas","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hanselmw/archytas","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanselmw%2Farchytas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanselmw%2Farchytas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanselmw%2Farchytas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanselmw%2Farchytas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanselmw","download_url":"https://codeload.github.com/hanselmw/archytas/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanselmw%2Farchytas/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32354567,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","firmata","iot"],"created_at":"2024-11-05T10:35:53.495Z","updated_at":"2026-04-27T20:32:26.193Z","avatar_url":"https://github.com/hanselmw.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# archytas\n\n[![Build Status](https://travis-ci.org/hanselmw/archytas.svg?branch=master)](https://travis-ci.org/hanselmw/archytas)\n\n**archytas** provides access to [Standard Firmata](http://archytas.org/) commands via Clojure/clojurescript \nand then some extra functionalities.\n\nThis project is heavily based on [peterschwarz/clj-firmata](https://github.com/peterschwarz/clj-firmata), you could consider it as a fork of it.\n\n## Usage\n\nAdd the following to your `project.clj` dependencies\n\n```clojure\n[archytas \"0.1.0-SNAPSHOT\"]\n```\n\nFor Clojurescript usage, see [here](doc/clojurescript.md)\n\n### Connect to a Board\n\nConnecting to a board is a simple as\n\n```clojure\n(use 'archytas.core)\n(def board (open-serial-board \"ttyACM0\"))\n```\n\nreplacing `ttyACM0` with the name or path of the appropriate serial port,\narduinos tend to use that port name on linux.\n\nAn valid serial port of a connected arduino may be autodetected by passing `:auto-detect`  Currently, this only works on Mac OS X and Linux.\n\n### Communicating with the board.\n\nPerforming simple queries on the board will result in events placed onto the board's `core.async` event channel.\n\nFor example, calling will result in an event of type `:firmware-report` to be placed on the channel.  I.e. the following would be true:\n\n```clojure\n(let [ch    (event-channel board)\n      _     (query-firmware board)\n      event (\u003c!! ch)]\n  (is (= :firmware-report (:type event)))\n  (is (= \"2.3\" (:version event)))\n  (is (= \"Firmware Name\" (:name event))))\n```\n\n#### Setting Pin Values\n\nSetting a digital pin value to HIGH (1)\n\n```clojure\n(set-digital board 13 :high)\n```\n\nand likewise to LOW (0)\n\n```clojure\n(set-digital board 13 :low)\n```\n\nFor analog values a pin must be in `:pwm` mode:\n\n```clojure\n(set-pin-mode board 11 :pwm)\n(set-analog board 11 255)\n```\n\nThe above will set the brightness of an LED on pin 11 to maximum brightness\n\n#### Receiving Information\n\nThe Firmata protocol provides several ways of receiving events from the board.  The first is via an event channel:\n\n```clojure\n(let [ch (event-channel board)]\n  ; ...\n  ; take events from the channel\n  ; ...\n  ; Then, when you're done, you should clean up:\n  (release-event-channel board ch))\n```\n\nThe channels have the same buffer size as the board is configured with on `open-board`.\n\nThe protocol also provides a `core.async` publisher, which publishes events based on `[:event-type :pin]`.  This can be used in the standard fashion:\n\n```clojure\n(let [sub-ch (chan)]\n  (sub (event-publisher board) [:digital-msg 3] sub-ch)\n  (go (loop\n        (when-let [event (\u003c! sub-ch)]\n          ; ... do some stuff\n          (recur)))))\n```\n\nTo enable digital pin reporting:\n\n```clojure\n(-\u003e board\n  (set-pin-mode 3 :input)\n  (enable-digital-port-reporting 3 true))\n```\n\nThis will result in the following events on the channel:\n\n```clojure\n(let [ch    (event-channel board)\n      event (\u003c!! ch)]\n   (is (= :digital-msg (:type event)))\n   (is (= 3 (:pin event)))\n   (is (= :high (:value event)))\n```\n\nBy default, the pin value is returned as a key word, either `:high` or `:low`. This may be changed by using the `:digital-result-format ` option when opening the board.  For example:\n\n```clojure\n(def board (open-serial-board \"ttyACM0\" :digital-result-format :raw))\n```\n\nWith this board instance, any read or report of a digital pin's HIGH/LOW state will be `1` or `0`, respectively.  One can use `:keyword`, `:boolean`, `:char`, `:symbol` and `:raw`.  The default is `:keyword`.\n\nOne can also write a custom digital formatter by passing a function for the `:from-raw-digital`:\n\n```clojure\n(def board (open-serial-board \"ttyACM0\" \n                              :from-raw-digital #(if (= 1 %) :foo :bar)))\n```\n\nWith this board instance, any read or report of a digital pin's HIGH/LOW state will be `:foo` or `:bar` respectively\n\nFor convenience, the `archytas.async` namspace provides the function `digital-event-chan`, which creates a channel with filtered events with the `:digital-msg` type and a specific pin.  For example:\n\n```clojure\n(let [ch (digital-event-chan board 3)]\n  (go-loop [evt (\u003c! ch)]\n    (if (= :high (:value evt)) \"Pressed\" \"Released\")))\n```\n\nThis ch can be closed like any other:\n\n```clojure\n; Assuming (require '[clojure.core.async :as a])\n(a/close! receiver)\n```\n\nSimilarly for analog in reporting (on `A0` in this example):\n\n```clojure\n(enable-analog-in-reporting board 0 true)\n```\n\nwill result in the following events on the channel:\n\n```clojure\n(let [ch    (event-channel board)\n     event (\u003c!! ch)]\n    (is (= :analog-msg (:type event)))\n    (is (= 0 (:pin event)))\n    (is (= 1000 (:value event)))\n```\n\nLike `digital-event-chan`, there is an `analog-event-chan` which will provide the events to a particular analog pin.\n\n### Exceptions and Error handling\n\nAny exceptions that occur while reading or writing to the board will be forwarded along the event channel. \n\n### Close the connection to a Board\n\nBoard connections should be closed when complete:\n\n```clojure\n(close! board)\n```\n\nAny channels will be closed as well.\n\n## License\n\nCopyright © 2017 Hansel Wave \u0026 Victor Vanegas.\n\nDistributed under GPL3.\n\n\nLicense of the project which Archytas is based on, clj-firmata:\n\nCopyright © 2014 Peter Schwarz\n\nDistributed under the Eclipse Public License, the same as Clojure.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanselmw%2Farchytas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanselmw%2Farchytas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanselmw%2Farchytas/lists"}