You are on page 1of 5

Biomedical Instrumentation – Supplementary Document Instructor: Hoan Thanh Ngo

LAB 2
(Homework)
---

Introduction to Qt Designer
Basic Serial Communication and
Multi-threading in Python

1
Biomedical Instrumentation – Supplementary Document Instructor: Hoan Thanh Ngo

1.Qt Designer
Exercise 1: Bau Cua Tom Ca – A Vietnamese traditional game

Bau Cua Tom Ca Game


Description
Select one choice by clicking Bau, Cua, Tom, or Ca.
Click on Roll to get the random result.
Hint

You can use self.pushButton.setStyleSheet("background-color: red") to set the


color of the button.
You can use import random to get random numbers and convert them to choices: Bau, Cua,
Tom, or Ca

2
Biomedical Instrumentation – Supplementary Document Instructor: Hoan Thanh Ngo

2.GUI-based Serial Communication


Exercise 2: Combo Box for serial communication

A simple GUI-based serial communication


Description
This exercise is similar to the example 4.5 you practiced in lab 2. However, we now use combo
boxes to select COM port and baud rate instead of letting users to enter.
Once you select COM port, baud rate and then click on the button Connect

 The “Disconnected” label changes to “Connected”.


 The text on the Connect button changes from “Connect” to “Disconnect”.
 Print the name of the COM port you connected to the console.
Hint
Refer https://www.tutorialspoint.com/pyqt/pyqt_qcombobox_widget.htm for how to use the combo
box widget

3
Biomedical Instrumentation – Supplementary Document Instructor: Hoan Thanh Ngo

Exercise 3: Morse Translation

Morse codes of 26 letters and 10 numbers (source: Wikipedia)

4
Biomedical Instrumentation – Supplementary Document Instructor: Hoan Thanh Ngo

Morse GUI

Description
Select COM port and baud rate and then click on Connect button to connect to establish the serial
communication between the computer and Arduino.
Select a key from the virtual keyboard on the right.
Transmit the selected key to Arduino.
Arduino receives the key and blink the built-in LED according to the Morse code table (Fig. 3).
Hint
You can refer https://www.instructables.com/id/Morse-code-with-arduinoLED/ for how to
implement Morse encoder in Arduino.

The end -

You might also like