Skip to content

tomas-fryza/avr-course

Repository files navigation

AVR course

The repository contains AVR lab exercises for bachelor course Digital Electronics 2 at Brno University of Technology, Czechia. The course focuses on digital circuits, microprocessor technology, embedded systems and uses the C and ASM languages for programming 8-bit Arduino microcontrollers in PlatformIO and Visual Studio Code IDE.

avr_course

Installation

PlatformIO is a cross-platform build system that can be used to develop software platforms for Arduino, ESP32, PIC32, and AVR. PlatformIO can be used with VS Code to provide a powerful set of tools to assist you in development [1], [2].

  1. Download and install Visual Studio Code source code editor.

  2. Run Visual Studio Code, open up the extensions viewer in menu View > Extensions Ctrl+shift+X, and then typing PlatformIO into the search bar. Press Install button on the result PlatformIO IDE.

    Install PlatformIO IDE

    It may take a few minutes depending on your connection speed. Do not close any window and do not open other folders until the installing process is completed. After that, restart the Visual Studio Code.

  3. Install Arduino framework: Click on the PlatformIO icon in the left-hand margin, then in menu PIO Home > Platforms > Embedded. Type AVR as a platform's filter and select Atmel AVR. Click on the Install button.

    Install Arduino framework

Usage

  1. Create a new project: Click on the PlatformIO icon in the left-hand margin, then in menu PIO Home > Open > New Project. Type blink as project name, select Arduino Uno board, keep Arduino framework, and select location to your working folder. Click on the Finish button.

  2. Code the application: Copy/paste blink example code from this repository to your BLINK > src > main.cpp file.

    Rename source file main.cpp to main.c, ie change the extension to .c.

  3. Compile and upload the code: The handy shortcuts for building and uploading the code is available on the blue footer taskbar. Hover over the icon to get its functionality. First, compile (Build) the project and then Upload it to Arduino Uno board. You can Clean up generated files as well.

    Control icons

    Command Palette: All available commands in VS Code are also accessible by F1 or Ctrl+Shift+P shortcut and followed by a command. Most useful commands in this course are:

    • PlatformIO: Build
    • PlatformIO: Upload
    • PlatformIO: Clean
    • PlatformIO: Upload and Monitor
    • PlatformIO: PlatfomrIO Home

VS Code shortcuts

Other common shortcuts in VS Code are:

Shortcut Usage
F1 or Ctrl+Shift+P Command Palette. Access to all of the VS Code functionality
Ctrl+K+O Open folder
Ctrl+K F Close folder
Ctrl+Tab Switch between open files
Ctrl+O Open a file
Ctrl+Shift+S Save all open files
Ctrl+Shift+V Open Markdown preview
Ctrl+K V Open Markdown preview to the side
Ctrl+B Toggle Sidebar visibility

Labs

  1. Programming in C
  2. Control of GPIO pins
  3. Timers
  4. Liquid Crystal Display (LCD)
  5. Universal Asynchronous Receiver-Transmitter (UART)
  6. Inter-Integrated Circuits (I2C)
  7. Assembly language and project documentation
  8. Project

List of examples

Components and tools

The following hardware and software components are mainly used in the lab.

Component Link(s)
ATmega328P microcontroler data sheet, instruction set
Arduino Uno board schematic
LCD and keypad shield schematic
Multi-function shield schematic
DHT12 I2C humidity and temperature sensor: data sheet
MPU6050 I2C gyroscope and accelerometer: data sheet
DS3231 I2C real time clock: data sheet
AT24C32 I2C EEPROM memory module: data sheet
HC-SR04 Ultrasonic sensor: datasheet
Joystick PS2 Analog joystick PS2
Rotary encoder tutorial
Touch sensor TTP223 touch sensor module: tutorial
IR module HW-201 IR obstacle avoidance module: tutorial
GPS module GPS module NEO-6M GYNEO6MV2
Bluetooth modules HC-05
Servos Micro servo SG90
Soil moisture sensor tutorial
Relays Modules with 1, 2, and 4 relays
Displays HD44780-based, Nokia displays, 4-digit LED display TM1637, 8x8 LED display MAX7219
OLED display I2C OLED display 128x64, driver SH1106
Keypad 4x4 keypad: tutorial
Basic components Pasive and active components: push buttons, resistors, 10kohm potenciometers, (multicolor) LEDs, LED bargraphs, N-MOSFET transistors 2N7000, [light dependent resistor LDR, photoresistor](Light Dependent Resistor LDR, Photoresistor), IR LED 940 nm, IR receiver
Current sensor Current sensor 5A ACS712
ESP8266 Wi-Fi module AT commands
Logic analyzer 24MHz 8-channel logic analyzer: software
Osciloscope DSOX3034T Oscilloscope Keysight Technologies DSOX3034T (350 MHz, 4 analog channels), including 16 logic timing channels DSOXT3MSO and serial protocol triggering and decode options D3000BDLA
Multimeter Multimetrix DMM230
Visual Studio Code web page
PlatformIO web page
GCC Compilers for AVR web page
SimulIDE Real time electronic circuit simulator. With PIC, AVR and Arduino simulation: web page
Git git

Tested on

Version Result (yyyy-mm-dd) Note
macOS Sonoma 14.6.1 OK (2024-10-13) MacBook
Linux Mint 21.2 (Victoria) OK (2024-01-20) Laptop
Windows 10 OK (2022-09-08) Lab SC 6.61
Linux Mint 20.3 (Una) OK (2022-02-23) Laptop
Windows 10 OK (2021-11-25) Office
# FYI: How to check OS version in Linux
cat /etc/os-release

# Or by Neofetch
neofetch

# For Windows with CMD
WINVER

References

  1. Peter Fleury, AVR-GCC libraries

  2. Barr Group, Embedded C Coding Standard

  3. 4Geeks. How to use Gitpod