Skip to content

Week 5 Microcontroller and programing

Microcontrollers are compact integrated circuits designed to govern specific functions in embedded systems. They combine a processor core, memory, and programmable input/output peripherals on a single chip, making them ideal for controlling devices in various applications, from household appliances to automotive systems.

This a simple block diagram about microcontroller and how it is work

Microcontroller some detals

Microcontroller Arduino UNO

Microcontroller UNO it was given to me in the first day. The microcontraller arduino UNO has many thig as showing in below

And this is some of information about it and some what I have search:

The image shows an Arduino Uno microcontroller board, a versatile platform for electronics projects. It features a USB-B port for connecting to a computer, a power input accepting 7 to 12 V DC, and a reset button. The board has digital pins (0 to 13) for input and output, analog pins (A0 to A5) for reading sensor data, and communication pins for I2C and SPI protocols. Some digital pins also support Pulse Width Modulation (PWM). This board is popular for its ease of use and extensive application in DIY and educational projects.

Visit our group assighment

esp32

XIAO ESP32-S3 Pinout for Digital I/O, Analog Input, and PWM

The XIAO ESP32-S3 is a versatile microcontroller featuring 11 digital I/O pins (D0-D10) that support both input and output functions, as well as Pulse-Width Modulation (PWM) capabilities for controlling brightness and motor speeds. Additionally, it includes 9 analog input pins (A0-A5, A8-A10) for reading analog signals from sensors and other devices. This flexibility makes it suitable for a wide range of applications.

Arduino !!

Arduino is an open-source electronics platform based on easy-to-use hardware and software. It consists of a microcontroller on a circuit board, along with a development environment that allows users to write and upload code to the board. Arduino is popular among hobbyists, educators, and professionals for building interactive projects, ranging from simple LED displays to complex robotics. Its user-friendly nature and extensive community support make it accessible for beginners while still powerful enough for advanced applications.

Download the app

First step we go to arduino website

Arduino Website

Then we go to software

After that I click on the windows because I this is my operating system

And the last step is clicking on the just downlaod

Add ESP32 board package

Navigate to File > Preferences, and fill “Additional Boards Manager URLs” with the url below:

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

Navigate to Tools > Board > Boards Manager…, type the keyword esp32 in the search box, I select the latest version of esp32, and install it.

On top of the Arduino IDE, I can select the port directly. This is likely to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports).

Also, search for xiao in the development board on the left. select XIAO_ESP32S3.

So in this steps I use XIAO ESP32-S3 to test it and to do that I go to Navigate to File > Examples > 01.Basics > Blink, open the program.

This is the code example

/*
  Blink

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:
  https://www.arduino.cc/en/Main/Products

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
*/

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(5000);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
} 

I select the board model to XIAO ESP32S3, and I select the correct port number to upload the program.

Once the program is successfully uploaded, I can see the following output message and I can observe that the orange LED on the right side of the XIAO ESP32S3 is blinking.

XIAO ESP32S3 is blinking as showing below

The second experiment using the microcontroller esp32 using Mu Editor that use micropython to program it and Arduino.

Mu Editor is a simple and lightweight code editor designed specifically for beginners learning to program with Python, particularly in educational settings. It features an intuitive interface, built-in support for running scripts, and a REPL (Read-Eval-Print Loop) for interactive coding. Mu Editor is particularly well-suited for use with microcontrollers like the BBC micro:bit and Raspberry Pi, making it an excellent tool for teaching programming concepts. Its focus on ease of use helps newcomers to quickly grasp coding fundamentals without being overwhelmed by complex features.

Search for Thonny website and download the first link

thonny.org

second steps to connect the Arduino and search for its name

The I do this steps:

We use this code to blanking the led light:

import machine
import time

print("Hello, ESP32!")
led = machine.Pin(18, machine.Pin.OUT)

# Define a simple melody with durations (in seconds)
melody = [
    (0.2, 1),  # Note on for 0.2 seconds
    (0.1, 0),  # Note off for 0.1 seconds
    (0.3, 1),  # Note on for 0.3 seconds
    (0.1, 0),  # Note off for 0.1 seconds
    (0.4, 1),  # Note on for 0.4 seconds
    (0.1, 0),  # Note off for 0.1 seconds
]

while True:
    for duration, state in melody:
        led.value(state)
        time.sleep(duration)

This will be the output as below

Visit our group assighment


Last update: January 17, 2025