Week 4 Embedded programming

It was a challenging week for me and I gained some embedded programming experience. Includes simple programming language, microcontroller features, etc. When the control program is running, it's really interesting.

Learning Objectives

Group assignment:

I have practiced embedded programming using both Arduino Uno and micro:bit v2.

1.Tech specs

1.1 Comparison Between Arduino Uno and micro:bit v2

Feature Arduino Uno micro:bit v2
Microcontroller ATmega328P nRF52833
Memory Flash: 32 KB, SRAM: 2 KB, EEPROM: 1 KB Flash: 512 KB, RAM: 128 KB
GPIO Pins 14 digital pins (6 support PWM), 6 analog input pins 25 programmable GPIO pins (including 3 analog inputs)
Communication Interfaces UART, SPI, I2C BLE, NFC, USB, SPI, I2C
Power Supply USB or External Power (7-12V) USB or Battery Pack (2xAAA Batteries)
Dimensions Approx. 68.6 mm x 53.4 mm Approx. 52 mm x 43 mm
Programming Environment Arduino IDE (Primarily C/C++) MakeCode, MicroPython
1 1

1.2 Arduino Uno

The Arduino UNO is the best board to get started with electronics and coding. Datasheet

1.2.1 Board topology

1 1

1.2.2 Schematic diagram

1 1

1.2.3 Connector Pinouts

1

🛠️1.2.4Install Arduino IDE on Windows

✅ Visit the Official Website Website

💾 Download for Windows,Click on Windows Installer (for Windows)

💻 Install the Arduino IDE

  1. Double-click the downloaded .exe file
  2. Accept the license agreement
  3. Select all components (default options are fine)
  4. Choose an installation location (or keep default)
  5. Click Install and wait for it to finish
  6. Click Finish to launch the Arduino IDE

1.2.5 Upload and Run Arduino Program

Step-by-Step Guide:

  1. 🔌 Connect the Arduino Board: Use a USB cable to connect the Arduino to computer.
  2. 🖥 Open Arduino IDEArduino official website.
  3. ⚙️ Select Board & Port:
    • Go to Tools → Board and select your Arduino Uno.
    • Go to Tools → Port and select the correct port COM5.
  4. 📋 Code: Open the code.
  5. Compile & Upload Code:
    • Click the ✔️ (checkmark icon) to verify the code.
    • Click the ⬆️ (upload icon) to upload the code.
  6. 📟 Open Serial Monitor:
    • Go to Tools → Serial Monitor .(shift+alt+M)
    • Set baud rate to 9600.
    • Check code

1.3 micro:bit v2

The micro:bit is a tiny programmable computer designed by the BBC for education. Datasheet

1

1.3.1 Connector Pinouts

1 1 1 1

1.3.2 How to Run a Program on micro:bit

🛠️ What You Need:

🧩 Method A: Using MakeCode (Block-Based Programming)

  1. Go to https://makecode.microbit.org
  2. Click "New Project" to start coding with blocks
  3. Click "Download" to get the .hex file
  4. Connect your micro:bit to your computer via USB
  5. Drag and drop the .hex file to the micro:bit drive
  6. The program will upload and start running automatically

🧑‍💻 Method B: Using Python (MicroPython)

  1. Go to https://python.microbit.org
  2. Write your Python code, for example:
from microbit import * while True: display.scroll("Hello!") sleep(1000)
  1. Click "Download" to get the .hex file
  2. Connect your micro:bit and drag the file into the drive

📌 Tips:

✅ Summary

Arduino Uno is ideal for more advanced users who want flexibility and hardware control. Great for robotics, sensors, and real-world device building.

micro:bit is perfect for beginners and education. It has built-in features that make learning fast and fun, especially in classrooms.

Individual assignment:

2.1 Dual-color light

Using an Arduino UNO board to design a red-green dual-color LED system

2.1.1 Code

1 1 1

2.1.2 Running & Testing

1 1

2.2 RGB light with seven colors

Using a micro:bit to create a seven-color LED system

2.2.1 Code

1

2.2.2 Running & Testing

1 1 1 1 1

2.3 Smiley face and heart button lights

Using a micro:bit to create smiley face and heart button lights>

2.3.1 Code

1

2.3.2 Running & Testing

1 1

2.4 Timer

Using a micro:bit to build a timer

2.4.1 Code

1

2.4.2 Running & Testing

Code2.1 for this week Code2.2 for this week Code2.3 for this week Code2.4 for this week