0% found this document useful (0 votes)
7 views

Week 4

Uploaded by

Thanh Nhật
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Week 4

Uploaded by

Thanh Nhật
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

MEDICAL DESIGN

Instructor : Tran Le Giang, Ph.D.


School of Biomedical Engineering
Email: [email protected]

TA: Nguyen Nhat Minh, B.Sc


Do Vy Ngoc
Nguyen Huu Trong Pham
Outline
1. Debugging using serial monitor
2. LCD 16x2
1. Debugging using serial monitor
• Definition: When working on ESP32 project, the Serial Monitor is a vital tool. It can
be used to debug, test out concepts or communicate directly with the ESP32 board.
But in this section, Serial Monitor will be used as debugging tool.
1. Debugging using serial monitor
• Syntax:
void setup() {
Serial.begin(Baud_rate);
}
void loop() {
Serial.print (“hello world!”);
delay(1000);
}
1. Debugging using serial monitor
• Components:
- Output console: displays data received from ESP32
1. Debugging using serial monitor
• Components:
- Auto-scroll checkbox: offers options to enable/disable the automatic
scroll on the output console
1. Debugging using serial monitor
• Components:
- Show timestamp checkbox: offers options to add the timestamp before
data
1. Debugging using serial monitor
• Components:
- Clear output button: When this button is clicked, the text on the output
console is clear
1. Debugging using serial monitor
• Components:
- Baud rate selection: offers options to select communicate speed
between PC and micro – controller.
1. Debugging using serial monitor
• Components:
- Textbox: allow users to type characters that will be sent to ESP32
board when they click Send button at the right side.
1. Debugging using serial monitor
• Components:
- Ending selection: offers options to select the ending characters
appended to data sent to ESP32.
1. Debugging using serial monitor
• How to use:
- After coding for ESP32, we can debug using serial monitor by click as the
below image:
2. LCD 16x2 – Cursor coordinate
• Understand the coordinate of LCD will help users to place the
text in the right position which they want
2. LCD 16x2 – without I2C
• LCD16x2 without I2C
- Pinout:
2. LCD 16x2 – without I2C
• LCD16x2 without I2C
- Connection:
+ VSS (ground): this pin is connected to the ground (GND) of the circuit
+ VCC (power supply): this pin is connected to the positive power supply
pin of the circuit (usually to +5V)
+ VEE (contrast adjustment): This pin is connected to the pin V_out of the
variable resistor to adjust the contrast of the LCD. It means we can change
the darkness of the characters by adjust the variable resistor
+ A (LED+): this pin is connected to the positive power supply pin of the
circuit (usually to +5V)
+ K (LED-): this pin is connected to the ground (GND) of the circuit
2. LCD 16x2 – without I2C
• LCD16x2 without I2C
- Connection:
+ RS (register select): this pin is connected with the digital pinout, and it is
used to select the register that the data or commands that will be sent.
+ RW (read/write): this pin is used to select whether the data is being written
to LCD or read from it. When RW is in low state (0), data is written to LCD,
when it is in high state (1), data is read from LCD .
+ E (enable): This pin is connected to the pinout of micro – controller and
used to enable the data transfer between ESP32 and LCD. A high – to – low
transition on this pin initiates the data transfer.
+ D4 – D7 (data bus): these pin is connected to the pinout of micro –
controller and used to send data and commands to the LCD.
2. LCD 16x2 – without I2C
• LCD16x2 without I2C
- Syntax:
+ Library: #include <LiquidCrystal.h>
+ Declaration: LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
+ Set up: lcd.begin(col_num, row_num);
+ Set the position for the cursor: lcd.setCursor(column, row);
+ Print the data: lcd.print(“write the data here”);
+ Display the data: lcd.display();
+ Clear the data: lcd.clear();
2. LCD 16x2 – With I2C interface
• LCD16x2 with I2C
- Pinout:
2. LCD 16x2 – With I2C interface
• LCD16x2 with I2C
- Connection:
+ GND (ground): this pin is connected to the ground (GND) of the circuit
+ VCC (power supply): this pin is connected to the positive power supply
pin of the circuit (usually to +5V)
+ SCL (clock signal): this pin is connected to analog pinout of the ESP32
+ SDA (data signal): this pin is connected to another analog pinout of the
ESP32.
2. LCD 16x2 – With I2C interface
• LCD16x2 with I2C
- Syntax:
+ Library: #include <LiquidCrystal_I2C.h>
+ Declaration: LiquidCrystal_I2C lcd_i2c(0x27, col_num, row_num);
+ Initialize: lcd_i2c.init(); lcd_i2c.backlight();
+ Set the position for the cursor: lcd_i2c.setCursor(column, row);
+ Print the data: lcd_i2c.print(“write the data here”);
+ Display the data: lcd_i2c.display();
+ Clear the data: lcd_i2c.clear();
2. LCD 16x2 – How to use
• How to use:
Step 1: create a circuit. For LCD without I2C, connect RW to GND.
Step 2: Declare the LCD, this step must be done before the void setup()
Step 3:
+ With I2C: Initialize the LCD
+ Without I2C: Set up the LCD
Step 4: Print data, display, etc.
Exercise
Display mode selection and current blinking mode of the
last week Homework on the LCD.

You might also like