EEET2505 Introduction to Embedded Systems
Group Project
Team Members:
Huynh Hoang Duc – S3971496
Huynh Tan Phat – S3929218
Ngo Van Tai – S3974892
Date: 03 May 2024
Table of Contents
Introduction....................................................................................................................................................2
Hardware Design Setup.................................................................................................................................3
Software algorithm and explanation..............................................................................................................4
Results explanation........................................................................................................................................8
Unlisted YouTube link.................................................................................................................................14
Video script..................................................................................................................................................14
Conclusion...................................................................................................................................................14
Workload declaration for the following key items.......................................................................................16
Table Of Figures
Figure 1: Circuit diagram of the system........................................................................................................3
Figure 2: Visual Representation of the system..............................................................................................3
Figure 3: The system in practical...................................................................................................................3
Figure 4: Library included in the program.....................................................................................................4
Figure 5: Preprocessor Directives of the program.........................................................................................4
Figure 6: Key variables of the program.........................................................................................................5
Figure 7: Example of the variables’ purposes................................................................................................5
Figure 8: Example of detecting only-single button press..............................................................................6
Figure 9: Flowchart of the program...............................................................................................................6
Figure 10: Dash Function...............................................................................................................................7
Figure 11: Dot Function.................................................................................................................................7
Figure 12: SOS() function implementation....................................................................................................8
Figure 13: Start Signal pattern.......................................................................................................................8
Figure 14: Start signal measurement by OSC................................................................................................9
Figure 15: Stop signal pattern........................................................................................................................9
Figure 16: Stop Signal measurement by OSC.............................................................................................10
Figure 17: Measurement Dash function.......................................................................................................10
Figure 18: Measurement Dot function.........................................................................................................10
Figure 19: Delay time measurement............................................................................................................11
Figure 20: Duc Morse’s message pattern.....................................................................................................11
Figure 21: Duc message measurement in OSC............................................................................................11
Figure 22: Phat Morse’s message pattern....................................................................................................12
Figure 23: Phat message measurement in OSC...........................................................................................12
Figure 24: Tai Morse's message pattern.......................................................................................................12
Figure 25: Tai messages measurement in OSC............................................................................................12
Figure 26: SOS Morse Message Pattern......................................................................................................13
Figure 27: SOS message measurement in OSC...........................................................................................13
1
Table 1: Detailed breakdown of the workloads of the report 15
Table 2: Gantt Chart.....................................................................................................................................16
Introduction
The ability to integrate software into hardware implementations is at the core of the prevalent and con -
stantly developing field of embedded systems. In this group assignment, which is a part of EEET2505 -
Introduction to Embedded Systems, students are challenged to connect theories with practical applications
through the development of a Morse Code Flasher circuit. By utilizing the Arduino AVR microcontroller,
the project not only revisits a classic form of communication - Morse code - but also improves the under-
standing of basic concepts such as GPIO, electric circuits, and the Arduino development environment.
Morse code, with its significant historical relevance, provides a simple way to encode text characters into
a sequence of signals. In this project, Morse code is used to execute an embedded system capable of send-
ing signals representing the names of team members and an SOS message. The type of message to be sent
is controlled by button inputs from the user. The objectives of this assignment are to teach students the
skills required to develop simple embedded systems, familiarize them with the hardware and software as-
pects of the AVR microcontroller, and improve their teamwork abilities through collaborative work. This
report provides a detailed account of the process involved in building the Morse Code Flasher and dis-
cusses the technicalities of the system.
Project Scope
The objective of this project is to design an embedded device that can transmit Morse code messages
based on the pressing of a button, using an Arduino Uno and various electrical components. The imple -
mentation will involve both hardware and software components.
Software Setup
By using the C language and Arduino IDE, the hardware must be programmed as following instructions.
The system will have three stages. The first stage is when users press the button twice, the LEDs will
flash to transmit the signal to Morse code based on the name of each member. By pressing the fourth
time, the S.O.S. message will be delivered. In the last stage, which is the sixth time of pressing the button,
the device does nothing and reset the press time to zero time. Before delivering each main stage, the mes -
sage should also include start and stop prosing designed by the team to easily distinguish when testing the
program. There will be also a fixed delaying time unit to be obeyed after each character or word. In this
program, the one-time unit is 200 milliseconds. The message is only delivered once after each stage. For
example, after the user presses the button twice to make it to the first stage. The LEDs will flash out the
name of the members 1 time and stop. It will only deliver the S.O.S message once the user triggers stage
two by pressing the button twice. Similarly, the S.O.S message is only transmitted one time.
Hardware Preparation
The device will require three LEDs, each with a different color - red, blue, and green. These LEDs will be
used to convey the main message, dot message, and dash message respectively. Also, a button will be in-
2
corporated to let the user manipulate the stages of message delivery. By combining the software setup and
hardware preparation, the embedded device can transmit Morse code messages based on user inputs.
Hardware Design Setup
Figure 1: Circuit diagram of the system. Figure 2: Visual Representation of the system.
Figure 3: The system in practical.
Explanation of the hardware setup
The design includes the Arduino UNO, three LEDs, four resistors, a button, and a power source.
Arduino UNO
A popular microcontroller based on the ATmega328P. The design uses six pins of the circuit board, in-
cluding four digital I/O pins (PB0, PB1, PB2, and PD2), a GND pin, and a 5V pin.
LEDs and Resistors
3
The three LEDs used in this design are in different colors: red, blue, and green. Each LED is connected in
series with a 220-ohm resistor. This resistor is used to limit the current through the LED, preventing the
LED from drawing too much current and burning out. The anode of each LED is connected to the Ar -
duino via the resistors and a male-male wire, while the cathodes of all LEDs are connected to the ground
rail. The LEDs are controlled by digital pins PB2, PB1, and PB0. When these pins are set to HIGH (5V),
current flows through the resistors and LED, lighting up the LED.
Purpose of each LED
In this system, each LED serves a specific purpose related to signal duration. The blue LED indicates dot
signals, lighting up for a duration of one-time unit, or 200 milliseconds, as defined by the team. Con-
versely, the green LED denotes dash signals, remaining illuminated for three time-units, or 600 millisec-
onds. The red LED, the main signal relay, can represent both dots and dashes. Depending on the signal, it
lights up for either one or three time-units. It is important to note that, in normal operation, two LEDs will
be active simultaneously either the red and blue LEDs for dot signals or the red and green LEDs for dash
signals. During a signal gap, no LEDs will be illuminated.
Button
There is a button connected between the ground and the digital pin PD2 on the Arduino UNO. A pull-up
resistor R4 (220 ohms) is connected between the 5V supply and the pin PD2. This resistor ensures that the
pin reads HIGH when the button is not pressed. When the button is pressed, the pin is connected directly
to the ground, which makes the Arduino read a LOW.
Power Supply
The 5V and GND pins from the Arduino are used to power the circuit. The 5V pin supplies power to the
LEDs and the pull-up resistor for the button. The GND pin is connected to the common ground rail of the
circuit, which is necessary to complete the electrical circuit for the LEDs and the button.
Software algorithm and explanation
To set up a full software that delivers Morse message by pressing the button, we need to prepare for the
variables to serve the purpose of manipulating the button, the LEDs, and the algorithms to instruct the
hardware to have wanted behaviors. Firstly, the program needs to include the necessary libraries to use af-
terward. Based on the requirements, the two libraries shown in Figure will be exploited. We need to use
the basic Arduino library to manipulate the ports and the delay function to control the delay time of the
Morse message.
Figure 4: Library included in the program.
Preprocessor Directive
Some of the fixed variables are defined with symbolic constants, which makes the code readable and
maintainable. As shown in Figure 5, the pin for red, blue, and green LED is defined as PB0, PB1, and
4
PB2 respectively. Meanwhile, the button pin is set as PIND2 of port D of the Arduino. There are some
variables such as debounce time, reset time, and time unit are defined with fixed values in this section.
Figure 5: Preprocessor Directives of the program.
Program Setup
In the main program, we are going to have another variable that serves the purpose of directing the algo -
rithms. Firstly, we set three LED pins as output by configuring the data direction for the corresponding
bits in the Data Direction Register B (DDRB) to 1 and set the LED pin to 0 to avoid any unintended sig-
nals start phase. Subsequently, we configure the button pin as an input by setting the corresponding bit to
0 and using the pull-up resistor setup to avoid a “floating” pin state. In this setup, by default the button
pin is in a high state or logical ‘1’, when the button is pressed the pin connects to the ground or logical
‘0’. Moreover, there are 7 variables to serve some purposes, as shown in figure 6.
Key Variables
Figure 6: Key variables of the program.
The first variable, lastButtonState will store the last button state of the button, it will iteratively update at
the end of each loop. In addition, the buttonPressCount is the system’s counting, it will automatically in-
crement whenever the button is clicked. The isPerformingMorse serves as the Boolean to manage the
morse code execution. For example, as shown in Figure 7, whenever satisfying the condition, the isPer-
forming will toggle itself. Initially, the isPerformingMorse is 0, after going to the if statement, it becomes
1 and conveys the messages. Next time go to the loop again, the isPerformingMorse will toggle to 0 and
go to the else statement. This helps the system avoid going to the if condition again when it already per -
forms the messages.
Figure 7: Example of the variables’ purposes.
5
The else statement edits the stage variable to 1 and lastButtonCount to 2. The large if condition now is not
matched anymore since the stage is not 0. Additionally, the pressTimer and lastButtonPressCount serve the
detect single press function. While pressTimer stores the duration since the first press, the lastButtonPress-
Count keeps track of the counting of the previous stage’s presses. The stage to keep track of the stage of the
program. Finally, the isPressed serves the advanced function, whenever the button is pressed, the isPressed
will be set to 1. Then, after each loop, the program satisfies the condition and makes the comparison between
pressTimer and RESET_TIME, if the pressTimer exceeds the RESET_TIME, the press counting system will
be set to the previous stage. Otherwise, the application increases the pressTimer by DEBOUNCE_TIME.
Figure 8: Example of detecting only-single button press
Main program
6
Figure 9: Flowchart of the program.
Link to flow chart
The program operates with a big while loop, divided into three key stages. Initially, the system remains in
a quiescent state in the first stage, waiting for the button to be pressed. When the users press the button
twice, the program transmits to the second stage sending the Morse code of our three team members’ first
names, including start and stop signals. Subsequently, if the program detects another two presses, the
LEDs will perform the SOS morse code with start and stop signals at the beginning and the end of mes-
sages. Completing the cycle, an additional double press will return the system to the first stage, the quies-
cent stage, awaiting the button interactions.
Furthermore, to enhance our application, our program is only a response to the double-click actions. Upon
a single press, the system will wait for three seconds, if the system still doesn’t detect the second click
within the reset time, the counting press system will reset to the previous state. For example, if the system
is currently in the initial stage with the button press counting is 2, when the button is pressed once, the
button press counting will update to 3. Absent a follow-up click within the pre-defined reset time (3 sec-
onds), the counting will be reset to 2, asking users to perform another double click to transfer to the next
stage.
7
Functions
The dash function performs the dash signal in Morse code by turning on red and green LEDs. The config-
uration for this is to set the corresponding pins on PORTB to a high state. After keeping the signal on for
a predefined duration (600ms), the function will set the pins back to ‘0’ to turn off the LEDs. Addition -
ally, the dot function performs the dit or dot signal in Morse code. The structure of the function dot corre -
sponds with the dash function. In the dot function, the blue LED will turn on instead of the green LED,
and the delay duration is 200ms.
Figure 11: Dot Function
Figure 10: Dash Function
The dot and dash functions play key roles in the program, performing the Morse code elements. These
two functions are invoked repeatedly by the remaining functions to implement the Morse code in the spe-
cific order. In particular, the SOS messages will obey the Morse code schema of ‘S’, ‘O’, and ‘S’ charac-
ters to convey the message correctly on the LEDs.
Figure 12: SOS() function implementation
Results explanation
By manipulating PB0, PB1, and PB2, which are presenting for red light, blue light, and green light re-
spectively, we can deliver meaningful Morse code messages. In Morse code, two main functions serve the
purpose of transferring a dot (short mark) or a dash (long mark). The first function is the dot () function,
which is for sending the short mark signal, it will have a delay time of 200 milliseconds after the red and
8
blue LED light up. In contrast, the dash () function is for manipulating the long mark signal. The delay
time for this function will be three times longer than the short mark function which is 600 milliseconds
after the red and green LED turn up.
With the two functions, we can transport the START signal, STOP signal, the name of each member, and
SOS message based on the Morse code theory. The gap between each signal will be 200 milliseconds.
Each rectangle in the signal pattern presents for one time unit which is 200 milliseconds.
START Signal
The start signal will be triggered at the beginning of every message. It will be 3 seconds in total. Figure
13 and figure 14 demonstrate the signal pattern and the measured signal in Oscilloscope.
Figure 13: Start Signal pattern.
Figure 14: Start signal measurement by OSC.
As shown in Figure 14, it will start with a long mark of 600 milliseconds long, there will be three long
marks in total and two short marks interleaved after a long mark.
STOP Signal
A stop signal is used when it is the end of the main message. The signal will last for 2.61 seconds.
9
Figure 15: Stop signal pattern.
Figure 16: Stop Signal measurement by OSC.
The signal wave in Figure 16 shows it starts from a short mark and ends by a short mark. In contrast with
the start signal, long marks will be interleaved between the three short marks.
Dash and dot functions
Dash(): One of the important functions of the program is the dash function. It will trigger the electrical
signal in a total time of 600 milliseconds.
Dot(): In contrast with Dash () function, Dot () function only lasts for one time unit, or 200 milliseconds
as demonstrated in Figure 18.
10
Figure 17: Measurement Dash function Figure 18: Measurement Dot function
Delay time after every main message.
After delivering main messages such as the name of all members or S.O.S messages, there will be a
longer delay time, which is seven times larger than one unit time. The delay will be 1.4 seconds which is
one-unit times seven as measured in Figure 19.
Figure 19: Delay time measurement.
Member name messages
As illustrated in Figure 21, DUC message will be divided into three parts “D”, “U”, and “C”, each word
will be separated by a delay time of 600 milliseconds. As measured, the total message time will be 6.22
seconds.
Figure 20: Duc Morse’s message pattern.
11
Figure 21: Duc message measurement in OSC.
The name “PHAT” contains four characters, so each character will be separated by a delay time of 600
milliseconds. The message will be 7.02 seconds in total.
Figure 22: Phat Morse’s message pattern.
Figure 23: Phat message measurement in OSC.
12
The name is made of three letters. Each character will be separated by a delay time of 600 milliseconds.
Figure 24: Tai Morse's message pattern.
Figure 25: Tai messages measurement in OSC.
SOS Message
The same as other message, each character will be divided by a delay time of 600 milliseconds.
Figure 26: SOS Morse Message Pattern
13
Figure 27: SOS message measurement in OSC.
Unlisted YouTube link
Link to our video.
Video script
0:00 – 0:12: Hello Doctor Hung! My name is Duc, I’ll be presenting our project. He is Phat, the operator
of our system, and Tai is the cameraman. These are our sID’s. First of all, I’d like to show you, our code.
0:13 – 0:22: This code controls LEDs to blink Morse code messages based on the button inputs. Initially,
we include necessary libraries and define necessary variables to make the code more readable.
0:23 – 0:44: Three LEDs are set to output mode. The main loop checks if the button is pressed. When
pressed twice, the LEDs blink a sequence spelling out team members’ names in Morse code. Four presses
trigger an SOS signal. Pressing six times resets the system. The system ensures accurate button press de-
tection using debounce delays and a timer to reset if the button isn’t pressed again within three seconds.
0:45 – 0:59: Regarding the overview of the project and the hardware setup, our system consists of three
main stages. Initially, all LEDs are off. After pressing the button twice, consecutively, it communicates
the start signal, the names of team members, and the stop signal, all in Morse code.
1:00 – 1:26: While the initial stage is running, I’ll go briefly over the technical details of the setup. We
used PORTB pins 0, 1, and 2 for the LEDs and PIND2 for the button. The pull-up resistor configuration
ensures that when unpressed, the button reads as high, or 1, and when pressed, it reads as low, or 0. All
resistors used are 220 ohms, we think that the value is sufficient to prevent the LEDs from burning.
1:27 – 1:50: Okay, back to the demonstration, the second stage sends out the start signal again, then an
SOS message and ends with the stop signal, only after the initial stage has finished and the button is
14
pressed two more times. Finally, the third stage resets the system, returning to stage 1, after the second
stage has finished and the button is pressed again twice.
1:52 – 2:08: We selected a time unit of 200 milliseconds based on our belief that it provides an appropri-
ate blinking speed for the system. Consequently, we assigned a duration of 200 milliseconds to each dot,
600 milliseconds to each dash, and 600 milliseconds to the gap between characters.
2:20 – 2:36: We've designed the system to use pull-up resistors on our buttons to avoid floating states, en-
suring stable input signals. We derived the pull-up resistor configuration and obtained the Morse code
from online sources to ensure the correct setup. The code itself was entirely developed by our team.
2:37 – 2:53: Another technical detail that we would like to demonstrate is that when you press this button
once and wait for over 3 seconds, and then press again. The LEDs will not flash as the button count will
have reset to the previous stage, and it will only flash after we press it twice.
Conclusion
Given the project's scope, we have created an Arduino setup that satisfies the specifications. We created a
gadget that can deliver Morse code. At the beginning of the project, we determined the pull-up setup of
the device so that we could develop the software based on the hardware installation. By using electrical
components such as a switch, resistors, and LEDs with different colors, we assembled these parts to have
a Morse-delivering device. To make the components behave as expected of the scope of the project, we
need to exploit C programming language and Arduino IDE to instruct the behavior of the setup. With ap -
propriate declarations of variables and port manipulations, we have successfully made the system work as
expected. By pressing the button two times, it will deliver Morse code of the names of every member of
the team, the S.O.S message will be transmitted by pressing the button the fourth time. Lastly, by pressing
the button six times, the program will go back to the first stage. Delaying times between dit, dash signal,
or the gap between each name or message are measured using the oscilloscope to evaluate the correctness
of the program.
Additionally, to make sure the device works correctly, we also made a demonstration video explaining
which part belongs to which member, the code, and the hardware setup and showing the behaviors of the
device. The video script is listed in the technical report to help watchers easier to follow. In the future, we
would like to improve our program with monitors to display the information. For example, it will have
one 7-segment for displaying the morse message, and one 7-segment for displaying the time so that we
can easily test the correctness of the delay time.
15
Workload declaration for the following key items
This project requires strong teamwork skills, task management, and time management. As a team, we di-
vided the tasks based on each person’s strengths and weaknesses. Therefore, each person would be as-
signed tasks that suit their best. For the tasks that can only be done as a team such as setting up the hard-
ware or debugging the software, we would arrange daily meetings to solve the problems together. Since
the setting up hardware and software task needed knowledge about circuits and deep discussion to evalu-
ate the correctness of the setup, we must do it together to achieve higher efficiency. By doing it together,
we could better understand the project knowledge, so we can have precise explanations in the report and
the video. We also arranged a meeting to discuss what should be in the video to optimize the clip's dura-
tion, but still deliver the content most completely.
Members Workload details
The member has a background in Robotics Engineering, which makes him
more familiar with circuits and electrical components. For this reason, he over-
Huynh Hoang Duc
saw explaining as well as making circuit visualizer in this project. In addition,
he is also the main presenter for the demonstration video.
The main task of this member was completing the report. He supervised and
checked through the technical paper. Together with Tai, he needs to measure
Huynh Tan Phat the wave form the Morse message and explain it in the third section of the re-
port. Also, the conclusion part and workload declaration are also done by the
members supervised through the report.
As he is pursuing his software engineering career, he designed the program’s
algorithm, flow chart and took responsibility in the third section in code expla-
Ngo Van Tai nation of the report. He was also doing the measurement to check the behaviors
of the embedded device. With his strong office skill, the member also did the
Gantt chart, and adjusted the report format.
Table 1: Detailed breakdown of the workloads of the report
16
Table 2: Gantt Chart
17