Microcontrollers Laboratory - Spring 2025
||| In the name of Allah |||
Contents presented in the Microcontrollers Laboratory course at the Department of Computer Science Engineering (CSE), Shiraz University, Spring 2025.
The main objective of this course is to review basic topics in microcontrollers, familiarize with microcontroller programming, and provide a basic understanding of their various applications in the electronics industry (such as the Internet of Things (IoT), Quadcopter (helishot, ...) control, etc.); the main focus is on programming and coding microcontrollers (high-level instructions) for computational and control tasks.
Note: this repository only contains the programs written for each test and to access educational materials (slides, videos, etc.), visit the following links ...
Course Features:
- The Arduino framework (the
Arduino.h
library) is used to program both Arduino-based and ESP32-based development boards. - In the first five sections, fundamental microcontroller concepts are explored using the Arduino Uno R3 development board, which is based on the ATmega328P microcontroller.
- Also, in the final two sections, more practical microcontroller topics (Internet connection and communication) are explored using the ESP32-WROOM-32 module, integrated on the DOIT ESP32 DEVKIT V1 development board.
Professor:
- Dr. Farshad Khunjush
Providers (TAs):
- Sepehr Azhdari (@azhdarii)
- Seyed Mahdi Mahdavi Mortazavi (@theMHD-120)
Arduino UNO R3 Datasheet link
Content provided:
- Basic videos:
- PlatformIO installation link
- Course introduction link
- Introduction to Arduino UNO:
- Main content
Test performed:
- Turning ON an LED with a push-button & pull-down resistor
Content provided:
Tests performed:
- Toggle the LED state and modifying (correcting) its functionality using
delay()
instruction & Two flags- The best delay value is achieved through trial and error (due to the spring structure of the push-button, its value may vary)
- Two flags for previous & current state of push-button
- This method works for push-button with both types of resistors (pull-up and pull-down); you can check
- Design a three-bit counter that counts with each click on the push-button
- Using previous push-button modifications (delay and flags)
- Adjusting LED brightness using Pulse-Width-Modulation (PWM as a timer/counter mode)
- The output is based on the duty cycle (to adjust LED brightness, armature speed, or...)
Content provided:
Tests performed:
- Adjusting LED brightness using PWM whose value is determined by serial input
- Displaying PWM waveforms on the oscilloscope with different duty-cycles (watch here)
- Duplex communication (chat) between two computers (systems) using two Arduino UNO boards
- One Arduino as the transmitter and another Arduino as the receiver (and vice versa)
- Serial.h: The main serial interface for communication between Arduino and our systems
- SoftwareSerial.h: The virtual serial interface for communication between two Arduino boards
- Note: To connect two Arduino boards, they must have a common ground
Content provided:
Tests performed:
- Switching between Red-Green-Blue colors and their paired-combinations, like a 3-bit counter
- Switching between Red-Green-Blue colors and their paired-combinations, using a Potentiometer
- Using a Potentiometer to get analog input
- Input range value (as digital value): 0-1023
Content provided:
Tests performed:
- Switching between RGB colors with fading (using a potentiometer as in section 4)
- Setting up the duty cycle for an output device (LED, armature or ...) using a Photocell and monitoring the input voltage & digital value
- Using Photocell (in code) is like using Potentiometer (both as analog inputs)
DOIT ESP32 DEVKIT V1 Datasheet link
Content provided:
- Introduction to ESP32:
- Main content:
Test performed:
- Sending GET and POST requests to a desired server (ESP32 as a client)
- GET request: A GET request in simple terms is a way to get data from a data source (server) over the internet
- POST request: A POST request in HTTP is used to send data to a server typically to create or update a resource
Content provided:
- Main content:
- Basic introduction to Quadcopters (for acquaintance):
- Description link (voice)
- Featured website link (in voice)
Tests performed:
- Running a web server on the ESP32 board (web server initialization)
- Using
WebServer.h
library
- Using
- RGB lighting with user-controlled remote control
- Remote control is done via an HTML page
- ESP32 as a web server can be in Access Point (AP) and Station modes
- To view the output result of this test, click here