Tutorial 1: Bye bye, Arduino

The goal of this tutorial is programming Arduino Uno board without using Arduino's IDE.

Ressources

Compilation toolchain

Your goal is to write a Makefile allowing compiling and flashing of the following code, that enables on-board LED (PB5, marked "L" on the PCB):

#include <avr/io.h>

int main() {
    // Enables and turn the PB5 pin ON (led)
    DDRB |= _BV(PB5);
    PORTB |= _BV(PB5);
}

Here are the main steps will have to follow:

  • Use avr-gcc, compiler to produce the binary
  • Use avr-objcopy to extract a "raw" binary (not elf)
  • Use avrdude, a tool to flash the board

Make it so that you will run:

  • make to build the firmware
  • make install to send the firmware on the board

To install the toolchain:

  • Ubuntu: apt-get install avrdude gcc-avr avr-libc
  • Windows: You can install Arduino, and then find the installation directory, the toolchain will be available there

Controlling a stepper

The Arduino kit you have provides a stepper motor (28BYJ-48) and its driver (ULN2003APG):

Plug - on GND, + on VIN on IN1, IN2, IN3 on IN4 on any GPIO you want.

To control it, you can simply switch it step by step:

IN1 BlueIN2 PinkIN3 YellowIN4 Orange
Step11100
Step20110
Step30011
Step41001

Use some delay to wait in between each phase.