Skip to content

14-Interface and Application Programming

Assignmwnta

Group assignment:

Compare as many tool options as possible. Document your work on the group work page and reflect on your individual page what you learned.

Individual assignment

Write an application for the embedded board that you made. that interfaces a user with an input and/or output device(s)

Learning outcomes

Implement a User Interface (UI) using programming and explore protocols to communicate with a microcontroller board that you designed and made.

Have you answered these questions?

Linked to the group assignment page. Documented your process. Explained the UI that you made and how you did it. Explained how your application communicates with your embedded microcontroller board. Explained any problems you encountered and how you fixed them. Included original source code (or a screenshot of the app code if that’s not possible). Included a ‘hero shot’ of your application running & communicating with your board.

The road map i made for this week can be accesed here

Group Assignment

You can access our group assignment here

Reflection

This week’s group assignment gave me a clearer understanding of how a microcontroller can interact with a user through different interfaces. We looked at both the Arduino Serial Monitor and Tkinter, and seeing them side by side helped me understand how each one operates in its own way. They each come with their own advantages and limitations, and comparing them made it easier for me to decide which tool would be more suitable for future projects.

Individual Assignment

The goal of this assignment is to create a simple user interface to interact with a microcontroller. In this project, an ultrasonic distance sensor (HC-SR04) is connected to my custom PCB, and the distance readings are displayed in real-time on the Serial Monitor.

Unlike a web-based interface, this approach provides a minimal, fast, and reliable interface that shows how the board communicates with a user interface without additional UI programming.

Electronics & Components Used

Component Description
Custom PCB Microcontroller board designed for Fab Academy projects
HC-SR04 Ultrasonic distance sensor
Jumper Wires For connections
Breadboard (optional) For easy wiring during testing
LED (optional) To indicate close distance visually

Wiring Diagram

Connections:

HC-SR04 Pin PCB Pin
VCC 5V
GND GND
Trig D2
Echo D3

Optional LED:

LED Pin PCB Pin
Anode D4
Cathode GND

Wiring Diagram Placeholder:
Insert wiring photo here


Code

// Ultrasonic Distance Display via Serial Monitor

const int trigPin = 2;
const int echoPin = 3;

void setup() {
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop() {
  // Send ultrasonic pulse
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Read echo time
  long duration = pulseIn(echoPin, HIGH);

  // Calculate distance in cm
  long distance = duration * 0.034 / 2;

  // Display distance on Serial Monitor
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");

  delay(500); // update every 0.5s
}

User Interface

The Serial Monitor acts as the user interface. The distance measured by the ultrasonic sensor is printed in centimeters and updated every 0.5 seconds.

Example Serial Output Placeholder:
Insert Serial Monitor screenshot here


Problems and Solutions

Problem Solution
Sensor reading was fluctuating Added a short delay (500ms) and could implement averaging for smoother readings
LED wiring optional mistake Double-checked the polarity and pin connections
Serial output not updating Confirmed correct baud rate (9600) and verified COM port connection

Improvements / Future Work

  • Display the distance on a web interface instead of Serial Monitor.
  • Add a visual bar or graph to represent distance for easier understanding.
  • Include a warning LED or buzzer for distances below a threshold.
  • Implement averaging or smoothing algorithm to stabilize readings.
  • Make the interface mobile-friendly for easier monitoring.

Reflection

This project demonstrates a simple but effective interface between a PCB and a user. Using a Serial Monitor interface ensures fast feedback with minimal programming. It highlights the importance of accurate wiring, sensor calibration, and data communication.

Compared to a web-based interface (like the one in Tsheyang Tshewang’s Week 14 project), the Serial Monitor approach is much quicker to implement and is ideal for testing and debugging sensors.

Through this assignment, I learned:
- How to use an ultrasonic sensor to measure distance.
- How to display real-time data using Serial communication.
- How to document and reflect on problems and improvements for interface programming.

Thank Youu


Last update: November 22, 2025