avr-car icon indicating copy to clipboard operation
avr-car copied to clipboard

Obstacle avoiding robot made with the avr-hal crate, all in Rust 🦀.

Rusty Car has been at RustFest 2020 🐯 :car: 🎸 !!

Check the presentation and the amazing music video at 23:00 ! Music by @llogiq

Robot car with ATmega328p (Arduino chip), made with :package: avr-hal

Working with Rahix's avr-hal to make a little robot :car:🐯 with 📡.

The circuit diagram is below:

Stuff:

If you are not used to/have no access to cheap electronic parts: 🛍🛒 You can also order a kit from Banggood or Ebay. Just search 2WD obstacle avoiding robot kit, there are many, many, many suppliers. Example: Ebay UK, Banggood... Also, there are great tutorials on assembling those robots!

If you love picking up electronics yourself:

Get started:

  1. Install avrdude. It's the utility to write in the ROM(read only memory) or the EEPROM (electrically erasable programmable read-only memory) of AVR microcontrollers. atmega328p, on the arduino uno is from this familly. When you'll run the file, the executable file will be in target/avr-atmega328p/debug/.elf

  2. Compile the project, or modify the executable flash_it.sh if you want to use it. It contains those lines:

// build in nightly
set -e cargo +nightly build


// burn on the board
avrdude -p atmega328p -c arduino -P /dev/tty.<your usb> -U flash:w:target/avr-atmega328p/debug/<name of the project>.elf:e

// can be removed, used to check the console on mac.
screen /dev/tty.<your usb> 57600

Details:

set -e is a bash command that will prevent your board to be flashed if an error is returned by cargo. You flash on the board with avrdude with your usb serial and your own elf file. You can get your USB with ls /dev/tty* | grep usb.

  • -p is "partno": the only mandatory option, tells avrdude what type of MCU is connected to the programmer
  • -c gives the programmer id from a list (luckily arduino is super common)
  • -U : perform a memory operation The screen command allows to see the console. 57600 is the baud rate, other established baud rates as `9600 are possible, but then you would need to change the program)

3. you can now run ./flash_it.sh and have the car running (hopefully).