{"id":13896768,"url":"https://github.com/zevv/nim-arduino","last_synced_at":"2025-04-04T15:14:21.130Z","repository":{"id":150599177,"uuid":"237191686","full_name":"zevv/nim-arduino","owner":"zevv","description":"Trying to get Nim integrated into arduino IDE","archived":false,"fork":false,"pushed_at":"2020-08-21T12:23:35.000Z","size":21,"stargazers_count":54,"open_issues_count":3,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-03T13:49:38.297Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Nim","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zevv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-01-30T10:42:00.000Z","updated_at":"2024-09-12T13:19:56.000Z","dependencies_parsed_at":"2023-06-11T17:15:11.533Z","dependency_job_id":null,"html_url":"https://github.com/zevv/nim-arduino","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zevv%2Fnim-arduino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zevv%2Fnim-arduino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zevv%2Fnim-arduino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zevv%2Fnim-arduino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zevv","download_url":"https://codeload.github.com/zevv/nim-arduino/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198466,"owners_count":20900081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-06T18:03:08.685Z","updated_at":"2025-04-04T15:14:21.100Z","avatar_url":"https://github.com/zevv.png","language":"Nim","funding_links":[],"categories":["Nim"],"sub_categories":[],"readme":"\n# Nim for Arduino\n\nLet's start with a warning: this project is only an experimental hack. The\nArduino development environment does not support other languages then C++, and\nthe authors of the Arduino IDE have not shown any interest in allowing 3d\nparty langauge integrations. To make this work, we create a fake compiler that\nlooks like a C++ from the perspective of the Arduino IDE, but is actually a\nwrapper around the Nim compiler.\n\nThe current status of this project is \"Works For Me, but Don't Complain If It\nDoesn't For You\". I *am* interested in any improvements, patches or other ideas\nto make this work better.\n\nThere are two distinct parts to this project:\n\n- The host side: on the host the Arduino toolchain is reconfigured to use the\n  Nim compiler by changing the normal recipes, this is done my overwriting some\n  Arduino IDE parameters in a `platform.local.txt` file. Instead of invoking\n  the normal AVR compiler, it will now invoke the `nim_arduino` tool, which\n  will cross-compile the sketch with the Nim compiler.\n\n- The Arduino side: in the sketch the `arduino` module can be imported, which\n  provides the binding from Nim to the usual Arduino standard library.\n\n\n## Setup\n\n- If running from git, first do `nimble install` to build the `nim_arduino`\n  tool, and `nimble develop` to make the library available in your default\n  `.nimble` repo.\n\n- Symlink or copy platform.local.txt into `$ARDUINO/hardware/arduino/avr`\n\n- Make sure ~/.nimble/bin is in your $PATH\n\n- Write your sketch and type Ctrl-R to compile as usual.\n\nNote: the below configuration will reconfigure the default toolchain for the\nArduino IDE, so you can no longer compile normal sketches. I am looking for a\nway to make this configurable, but that might require some changes from the\nupstream Arduino developers. For now, simply remove the `platform.local.txt`\nfile from the arduino tree to restore the original configuration.\n\n\n## Example\n\n```nim\nimport arduino\n\nsetup:\n  pinMode LED_BUILTIN, OUTPUT\n\nloop:\n  digitalWrite LED_BUILTIN, HIGH\n  delay 500\n  digitalWrite LED_BUILTIN, LOW  \n  delay 500\n```\n\n## Misc\n\nWhen using multiple source files, the Arduino IDE will concatenate all of those and feed them\nto the compiler, so this will not allow Nim to use the usual `import` mechanism. Instead, you\ncan enable code reordering feature in Nim to make this work as expected: use the following\npragma at the top of your sketch:\n\n```nim\n`{.experimental: \"codeReordering\".}`\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzevv%2Fnim-arduino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzevv%2Fnim-arduino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzevv%2Fnim-arduino/lists"}