<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="https://blog.implrust.com/feed_style.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <tabi:metadata xmlns:tabi="https://github.com/welpo/tabi">
        <tabi:base_url>https:&#x2F;&#x2F;blog.implrust.com</tabi:base_url>
        <tabi:separator>
            •
        </tabi:separator>
        <tabi:about_feeds>This is a web feed, also known as an Atom feed. Subscribe by copying the URL from the address bar into your newsreader. Visit About Feeds to learn more and get started. It&#x27;s free.</tabi:about_feeds>
        <tabi:visit_the_site>Visit website</tabi:visit_the_site>
        <tabi:recent_posts>Recent posts</tabi:recent_posts>
        <tabi:last_updated_on>Updated on $DATE</tabi:last_updated_on>
        <tabi:default_theme></tabi:default_theme>
        <tabi:post_listing_date>date</tabi:post_listing_date>
        <tabi:current_section>arduino-uno</tabi:current_section>
    </tabi:metadata><link rel="extra-stylesheet" href="https://blog.implrust.com/skins/lowcontrast_orange.css?h=43aaccb17d8ec616ace4" /><title>impl Blog for Rust - arduino-uno</title>
        <subtitle>impl Rust Blog Posts</subtitle>
    <link href="https://blog.implrust.com/tags/arduino-uno/atom.xml" rel="self" type="application/atom+xml"/>
    <link href="https://blog.implrust.com/tags/arduino-uno/" rel="alternate" type="text/html"/>
    <generator uri="https://www.getzola.org/">Zola</generator><updated>2026-08-15T00:00:00+00:00</updated><id>https://blog.implrust.com/tags/arduino-uno/atom.xml</id><entry xml:lang="en">
        <title>Can I Use Rust with Arduino Uno? Getting Started with Embedded Rust</title>
        <published>2026-08-15T00:00:00+00:00</published>
        <updated>2026-08-15T00:00:00+00:00</updated>
        <author>
            <name>implFerris</name>
        </author>
        <link rel="alternate" href="https://blog.implrust.com/posts/2026/08/arudino-uno-with-embedded-rust/" type="text/html"/>
        <id>https://blog.implrust.com/posts/2026/08/arudino-uno-with-embedded-rust/</id>
        
            <content type="html">&lt;figure&gt;
  &lt;img src=&quot;&#x2F;img&#x2F;2026&#x2F;08&#x2F;arduino-compatible-uno-blinky-with-rust.jpg&quot; alt=&quot;Arduino Uno compatible board running a Rust blinky program&quot;&gt;
  &lt;figcaption&gt;Arduino Uno compatible board&lt;&#x2F;figcaption&gt;
&lt;&#x2F;figure&gt;
&lt;p&gt;Embedded Rust keeps getting more mature, and most people use boards like the ESP32, Raspberry Pi Pico or STM32 with Rust. At least, those are the boards I have used most for Embedded Rust.&lt;&#x2F;p&gt;
&lt;p&gt;But what if you already have an Arduino Uno? Can you use Rust with it?&lt;&#x2F;p&gt;
&lt;p&gt;The answer is &lt;strong&gt;YES&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;The Arduino Uno uses the ATmega328P, an 8-bit AVR RISC microcontroller with 32 KB of flash memory, 2 KB of SRAM, and 23 general-purpose I&#x2F;O pins. With such limited resources, you might wonder if a Rust program can actually fit on the board.&lt;&#x2F;p&gt;
&lt;p&gt;This question sometimes comes up on social media. Some people see the large binary size of Rust programs on desktop and assume Rust will also be too large for microcontrollers. But Embedded Rust has a different side. With &lt;code&gt;no_std&lt;&#x2F;code&gt;, we can write programs without the standard library and target small microcontrollers directly. So instead of guessing, let’s try it on the Arduino Uno and see how much space our Rust program actually needs.&lt;&#x2F;p&gt;
&lt;p&gt;By the way, I didn’t have an Arduino Uno before this, and I had never coded with the Arduino IDE either. I just bought one (a cheap clone) to experiment with Rust :)&lt;&#x2F;p&gt;
&lt;div class=&quot;admonition tip&quot;&gt;
    &lt;div class=&quot;admonition-icon admonition-icon-tip&quot;&gt;&lt;&#x2F;div&gt;
    &lt;div class=&quot;admonition-content&quot;&gt;
        &lt;strong class=&quot;admonition-title&quot;&gt;TIP&lt;&#x2F;strong&gt;
        &lt;p&gt;Don’t judge Embedded Rust based only on the Arduino Uno experience. The AVR platform and avr-hal have their own limitations, and the experience can be quite different on other microcontrollers. For example, I like Embassy, which makes it easier to work across different boards and use async programming.&lt;&#x2F;p&gt;

    &lt;&#x2F;div&gt;
&lt;&#x2F;div&gt;
&lt;h2 id=&quot;avr-hal&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#avr-hal&quot; aria-label=&quot;Anchor link for: avr-hal&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
AVR HAL&lt;&#x2F;h2&gt;
&lt;p&gt;For programming the Arduino Uno with Rust, we will use &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;Rahix&#x2F;avr-hal&quot;&gt;&lt;code&gt;avr-hal&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;. It is a Hardware Abstraction Layer for AVR microcontrollers and boards such as the Arduino Uno.&lt;&#x2F;p&gt;
&lt;p&gt;For the Arduino Uno specifically, we will use &lt;code&gt;arduino-hal&lt;&#x2F;code&gt;. It is a batteries-included HAL for Arduino and similar boards. It is designed to abstract away the differences between boards as much as possible, so we can use a consistent API when working with different Arduino boards.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;development-setup&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#development-setup&quot; aria-label=&quot;Anchor link for: development-setup&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
Development Setup&lt;&#x2F;h2&gt;
&lt;p&gt;I am using an Ubuntu-based Linux distribution. For other operating systems, or if these steps change in the future, refer to the &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;Rahix&#x2F;avr-hal&quot;&gt;&lt;code&gt;avr-hal&lt;&#x2F;code&gt; repository&lt;&#x2F;a&gt; for the latest setup instructions.&lt;&#x2F;p&gt;
&lt;p&gt;First, install the AVR development tools and the required system packages:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; apt install avr-libc gcc-avr pkg-config avrdude libudev-dev build-essential&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;We also need &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;Rahix&#x2F;avr-hal&#x2F;tree&#x2F;main&#x2F;ravedude&quot;&gt;&lt;code&gt;ravedude&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;, a CLI utility that makes Rust development for AVR microcontrollers easier. It wraps &lt;code&gt;avrdude&lt;&#x2F;code&gt; for flashing and also provides access to the board’s serial console, similar to the Arduino IDE.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;cargo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; +stable install ravedude&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Finally, install &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cargo-generate&#x2F;cargo-generate&quot;&gt;&lt;code&gt;cargo-generate&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;. It is a Cargo subcommand that allows us to create a new Rust project from an template. We will use it to create our Arduino Uno project from the &lt;code&gt;avr-hal&lt;&#x2F;code&gt; template:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;cargo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; install cargo-generate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The &lt;code&gt;avr-hal&lt;&#x2F;code&gt; project currently uses the Rust nightly toolchain. Don’t worry about setting this up manually. The project template that we are going to use includes the required configuration, so we can simply use the template and let it take care of the Rust toolchain for us.&lt;&#x2F;p&gt;
&lt;p&gt;With the required tools installed, we are ready to create our first Rust project for the Arduino Uno.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;creating-the-project&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#creating-the-project&quot; aria-label=&quot;Anchor link for: creating-the-project&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
Creating the Project&lt;&#x2F;h2&gt;
&lt;p&gt;The &lt;code&gt;avr-hal&lt;&#x2F;code&gt; project provides a template that sets up the required configuration for our Arduino Uno project.&lt;&#x2F;p&gt;
&lt;p&gt;Run the following command:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;cargo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; generate&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant&quot;&gt; --git&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; https:&#x2F;&#x2F;github.com&#x2F;Rahix&#x2F;avr-hal-template.git&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The template will ask a few questions. Select &lt;strong&gt;Arduino Uno&lt;&#x2F;strong&gt; as the board and enter a name for your project. I will use “hello-blinky” as the project name.&lt;&#x2F;p&gt;
&lt;p&gt;Once the project is created, move into it:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# cd your-project-name&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-function z-builtin&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; hello-blinky&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;our-first-rust-program&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#our-first-rust-program&quot; aria-label=&quot;Anchor link for: our-first-rust-program&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
Our First Rust Program&lt;&#x2F;h2&gt;
&lt;p&gt;The project template already gives us a simple LED blink program in &lt;code&gt;src&#x2F;main.rs&lt;&#x2F;code&gt;. We don’t need to change anything for now.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;#&lt;&#x2F;span&gt;&lt;span&gt;!&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;no_std&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;#&lt;&#x2F;span&gt;&lt;span&gt;!&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;no_main&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword&quot;&gt;use&lt;&#x2F;span&gt;&lt;span&gt; panic_halt &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword&quot;&gt;as&lt;&#x2F;span&gt;&lt;span&gt; _&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;#[&lt;&#x2F;span&gt;&lt;span&gt;arduino_hal&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;::&lt;&#x2F;span&gt;&lt;span&gt;entry&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword&quot;&gt;fn&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; main&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;()&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; -&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-logical&quot;&gt; !&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;    let&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other&quot;&gt; dp&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name&quot;&gt; arduino_hal&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-type&quot;&gt;Peripherals&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;take&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;()&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;unwrap&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;    let&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other&quot;&gt; pins&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name&quot;&gt; arduino_hal&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;pins!&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other&quot;&gt;dp&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-comment&quot;&gt;    &#x2F;*&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-comment&quot;&gt;     * For examples (and inspiration), head to&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-comment&quot;&gt;     *&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-comment&quot;&gt;     *     https:&#x2F;&#x2F;github.com&#x2F;Rahix&#x2F;avr-hal&#x2F;tree&#x2F;main&#x2F;examples&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-comment&quot;&gt;     *&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-comment&quot;&gt;     * NOTE: Not all examples were ported to all boards!  There is a good chance though, that code&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-comment&quot;&gt;     * for a different board can be adapted for yours.  The Arduino Uno currently has the most&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-comment&quot;&gt;     * examples available.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-comment&quot;&gt;     *&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-type z-storage z-modifier&quot;&gt;    let mut&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other&quot;&gt; led&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-other&quot;&gt; pins&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;d13&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;into_output&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword z-control&quot;&gt;    loop&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-variable z-other&quot;&gt;        led&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;.&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;toggle&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;();&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;        arduino_hal&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;::&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;delay_ms&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant&quot;&gt;1000&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The Arduino Uno has an onboard LED connected to pin 13. The program configures the pin 13 as an output and toggles it every second, making the LED blink.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;running-the-project&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#running-the-project&quot; aria-label=&quot;Anchor link for: running-the-project&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
Running the Project&lt;&#x2F;h2&gt;
&lt;p&gt;Let’s build and upload the program to the Arduino Uno:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;cargo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; run&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;If &lt;code&gt;ravedude&lt;&#x2F;code&gt; cannot automatically detect the serial port, we can find it manually. On Linux, run:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;ls&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;dev&#x2F;ttyUSB&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;*&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;dev&#x2F;ttyACM&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;*&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;For my Arduino Uno clone, this shows &lt;code&gt;&#x2F;dev&#x2F;ttyUSB0&lt;&#x2F;code&gt;. Your port may be different.&lt;&#x2F;p&gt;
&lt;p&gt;Pass the detected port to &lt;code&gt;ravedude&lt;&#x2F;code&gt; using the &lt;code&gt;-P&lt;&#x2F;code&gt; option:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;cargo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; run&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant&quot;&gt; -- -P&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;&#x2F;dev&#x2F;ttyUSB0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;After the program is uploaded, the onboard LED should start blinking.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;how-big-is-the-rust-program&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#how-big-is-the-rust-program&quot; aria-label=&quot;Anchor link for: how-big-is-the-rust-program&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
How Big Is the Rust Program?&lt;&#x2F;h2&gt;
&lt;p&gt;Now, let’s see how much space our Rust program actually uses.&lt;&#x2F;p&gt;
&lt;p&gt;If we look at the generated files:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;ls&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant&quot;&gt; -lh&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; .&#x2F;target&#x2F;avr-none&#x2F;debug&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;We can see that &lt;code&gt;hello-blinky.elf&lt;&#x2F;code&gt; is around 70 KB:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;-rwxrwxr-x 2 user user  70K hello-blinky.elf&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;At first, this looks like it would not fit into the Arduino Uno’s 32 KB flash memory. But the ELF file also contains debugging information and other data used during development, so it is not the actual firmware size.&lt;&#x2F;p&gt;
&lt;p&gt;We can use the &lt;code&gt;avr-size&lt;&#x2F;code&gt; command to check how much flash and SRAM our program uses:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;avr-size&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant&quot;&gt; -C --mcu=atmega328p&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; target&#x2F;avr-none&#x2F;debug&#x2F;hello-blinky.elf&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;For our program:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;AVR Memory Usage&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;----------------&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Device: atmega328p&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Program:     262 bytes (0.8% Full)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;(.text + .data + .bootloader)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Data:          1 bytes (0.0% Full)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;(.data + .bss + .noinit)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;So our program uses only &lt;strong&gt;262 bytes of flash&lt;&#x2F;strong&gt; out of the Arduino Uno’s 32 KB. The 70 KB ELF file is not the actual firmware size.&lt;&#x2F;p&gt;
&lt;p&gt;In Embedded Rust, &lt;code&gt;cargo size&lt;&#x2F;code&gt; is also commonly used to check the size of a program. We can install the required LLVM tools with:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;rustup&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; component add llvm-tools&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name&quot;&gt;cargo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; size&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;   text    data     bss     dec     hex filename&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    262       0       1     263     107 hello-blinky.elf&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The release mode build can help reduce the firmware size. You can build it with &lt;code&gt;cargo build --release&lt;&#x2F;code&gt; (or run it with &lt;code&gt;cargo run --release&lt;&#x2F;code&gt;). However, for this program, it didn’t make much difference.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;more-examples&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#more-examples&quot; aria-label=&quot;Anchor link for: more-examples&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
More Examples&lt;&#x2F;h2&gt;
&lt;p&gt;The &lt;code&gt;avr-hal&lt;&#x2F;code&gt; project has a collection of examples showing how to work with different peripherals and features. There is a separate set of examples for the Arduino Uno.&lt;&#x2F;p&gt;
&lt;p&gt;You can find them in the &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;Rahix&#x2F;avr-hal&#x2F;tree&#x2F;main&#x2F;examples&quot;&gt;&lt;code&gt;avr-hal&lt;&#x2F;code&gt; examples&lt;&#x2F;a&gt; directory.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;final-thoughts&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#final-thoughts&quot; aria-label=&quot;Anchor link for: final-thoughts&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
Final Thoughts&lt;&#x2F;h2&gt;
&lt;p&gt;So, can you use Rust with an Arduino Uno? Yes. We just did it, and our first Rust program used only 262 bytes of flash.&lt;&#x2F;p&gt;
&lt;p&gt;The &lt;code&gt;avr-hal&lt;&#x2F;code&gt; project does not seem to have much recent development activity, and it currently uses the &lt;code&gt;nightly-2025-04-27&lt;&#x2F;code&gt; Rust toolchain. The project template uses the same nightly version. Because of this, tools such as Rust Analyzer can complain about the old toolchain, which makes development a little harder.&lt;&#x2F;p&gt;
&lt;p&gt;I have only tried a simple blinky so far, so I still need to build some real applications and see how the experience goes. I bought the Uno mainly to experiment with Rust.&lt;&#x2F;p&gt;
&lt;p&gt;Once again, if you want to see the better side of Embedded Rust, try the ESP32 family, Raspberry Pi Pico, or STM32. You should also explore the &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;embassy.dev&#x2F;&quot;&gt;Embassy framework&lt;&#x2F;a&gt;. Embassy is an async runtime for embedded systems, using Rust’s async and await features.&lt;&#x2F;p&gt;
</content>
        <summary type="html">Learn how to use Embedded Rust with the Arduino Uno. Get started with Rust on the ATmega328P and discover the tools and libraries needed to build your first Rust program.</summary>
        </entry>
</feed>
