DEV Community

Ryan Kopf, Owner of the Moon
Ryan Kopf, Owner of the Moon

Posted on

How to use Rust on Arduino (Windows Rust)

1 - Install Rust nightly compiler:

rustup toolchain install nightly

2 - Install Scoop via PowerShell:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
irm | iex

3 - Install avr-gcc and avrdude using Scoop:

scoop install avr-gcc
scoop install avrdude

4 - Install ravedude for flashing the microcontroller:

cargo +stable install ravedude

5 - Create a new project using cargo-generate:

cargo install cargo-generate
cargo generate --git

6 - Navigate into the project directory and open the folder in your preferred code editor.

7 - Edit the file to include your desired program.


use panic_halt as _;
use arduino_uno::prelude::*;

fn main() -> ! {
    let dp = arduino_uno::Peripherals::take().unwrap();
    let mut pins = arduino_uno::Pins::new(dp.PORTB, dp.PORTC, dp.PORTD);
    let mut led = pins.d13.into_output(&mut pins.ddr);
    loop {
        //Or Your Other Code Here
Enter fullscreen mode Exit fullscreen mode

arduino_uno = "0.2"

8 - Build the project:

cargo build

9 - Connect your Arduino board to your computer via USB.

10 - Set the serial com port for ravedude (replace COMx with the actual port number):


11 - Build and flash the program into the Arduino:

cargo run

12 - After these steps, the Arduino should execute the program as intended.

Top comments (0)