0% found this document useful (0 votes)
3 views15 pages

Act 2

The document outlines an educational activity involving the integration of an ultrasonic sensor and an LCD display using an ESP32 microcontroller. It aims to develop coding skills, hardware integration understanding, and real-time feedback through distance measurement and display. The expected outcomes include a functional system that efficiently communicates and displays information while optimizing wiring and pin usage.

Uploaded by

Kiko Mugi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
3 views15 pages

Act 2

The document outlines an educational activity involving the integration of an ultrasonic sensor and an LCD display using an ESP32 microcontroller. It aims to develop coding skills, hardware integration understanding, and real-time feedback through distance measurement and display. The expected outcomes include a functional system that efficiently communicates and displays information while optimizing wiring and pin usage.

Uploaded by

Kiko Mugi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 15
Ultrasonic wor and LCD Display WAM 2 ee ROOM/BUILDING: COURSE/YEAR: DATE PERFORMED: a SUBJECT: ~ DATE SUBMITTED: DAY/TIME/: INSTRUCTOR: = [Status Check| Evaluation Criteria | Poor | Fair | Good | Excellent Reasoning Advance Accuracy Completeness on Time Analytical Ability Late Neatness of Work | Remarks: 9 Rating Signature Date Objectives of the activity: +-Develop coding proficiency by programming the ESP32 to control the ultrasonics sensor, enabling participants to create patterns, measure the distance, and grasp fundamental coding concepts. “foster understanding of hardware integration as participants learn fo connect and configure the Ultrasonics sensor with the ESP32, gaining practical knowledge of pins, circuits, and the interaction between software and hardware components, Expected Outcome of the activity: 3. The goal is to connect an ultrasonic sensor to an ESP32, Precise distance measurement by calculating the time t ultrasonic signals to travel to an object and back. enabling aken for Utilizing the ultrasonic sensor in conjunction with the ESP32, the objective is to detect obstacles, allowing the system to respond by halting or adjusting its course for improved navigation. 3.The activity aims to showcase distance information from the ultrasonic sensor through a visual interface or alerts by programming the Arduino: to interact with devices such as an LCD display or LEDs, offering real-time feedback based on detected object proximity. I. INTRODUCTION The HC-SR04 ultrasonic sensor uses SONAR to determine the distance of an object just like the bats do. It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package from 2 cm to 400 cm or 1” to 13 feet. The operation is not affected by sunlight or black material, although acoustically, soft materials like cloth can be difficult to detect. It comes complete with ultrasonic transmitter and receiver module. TI. EQUIPMENTS and MATERIALS © -ESP32 © The HC-SRO4 ultrasonic sensor . Proteus software «LED Indicator XII. Schematic Diagram (@ Sst. For example, if the object is 10 cm awa 'y from the sensor, and the speed of the sound is 340 m/s or 0.034 en/us the sound wave will about 294 u seconds. But what you will get double that number because the sound waves bounce backward. So, in order to get multiply the received travel time value divide it by 2 need to travel from the Echo pin will be need to travel forward and the distance in om we need to from the echo pin by 0.034 and IV. Program code define trigpin 9 // titi define echopin B / define led 7 void setup() ize ping For Hc-sro4 +, / Initialize ping nitialize pini2 fo rigger ‘or HC-SRO4 Echo LED Serial.begin (96@8); PinMode(trigPin, OUTPUT); //Detine Pinode(echoPin, INPUT)5, /o. PinMode(led, OUTPUT); //oer + void loop() t long duration, distance; // variable to hold the ‘bon tics ‘Begin serial monitor with baud rate 9600 Trigger pin as output fine Echo pin ine LED pin as duration and 4: digitalwrite(trigpin, Low); // Weite trigger pi delayMicroseconds(2); y for 2microsecond digitalwrite(trighin, HIGH); //urite trigger pi delayMicroseconds(1@)5// Delay for 1enicraseconds GigitalWrite(trighin, LOW); //write tr duration is as high pin is as low ulseIn(echoPin, HIGH); //Read the ech distance = (duration*®.e34 / 2); // if (distance <= 160) ‘ Serial.print (distance); //print the distance value on serial port digitalwrite(led, HIGH); Serial.printIn(“cm : LED is on "); delay (see); z else { Serial.print(distance)3//print the distance value on serial port digitalWrite(led, Low); Serial.printin(” cm : LED is off "); delay(5e@); } } V. QUESTION AND ANSWER WHAT TS THE IMPORTANCE OF AN ULRASONIC SENSOR? WHAT ARE THE USES OF AN ULTRASONIC SENSOR? VI.CONCLUSION AND OBSERVATION 1. What did you learn in doing this activity? 2. During the activity, which factors significantly contribute to shaping your ability to successfully complete it? 3. What insights do you gain from participating in the activity as part of a group with teammates? LCD 12¢ Display Objectives of the activity: 3+ Design a functional Lcp I2c display system with an ESP32 to optimize wiring and conserve digital pins through efficient 12C communication. Demonstrate proficiency in programming by using the 12C protocol to establish simplified communication between the ESP32 and the LCD display. 3+ Showcase practical application by developing a user-friendly interface on the LCD 12¢ display with the ESP32, effectively conveying essential information and messaces Expected Outcome of the activity: 1. By the end, we expect a fully working LCD I2c display with the ESP32, showing that we can connect things more neatly and use fewer pins. 2. The goal is to make our ESP32 easily talk to the LCD display through 12C, proving that we can make them communicate in a simpler way. 3 We aim to have a display that shows important info and messages in a straightforward way, proving that using 12C makes our projects user- friendly and efficient. INTRODUCTION: The Liguidcrystal library allows you to control LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually find them by the 16-pin interface also learn how to use led.begin(), 1cd.print () functions You will and 1cd.setCursor () TI, EQUIPMENTS and MATERIAL: © Bsp32 © 16x2 LCD Modules © Proteus Lep 12¢ T2C is a way for differ Ricrocontroller and an an LOD is *12C-enabled, requires fewer wires using an I2¢ ent parts of an electronic device, like a IcD screen, to talk to each other. When we say it means it can communicate using a method that and is easier for the device to understand. So, 3 venabled LCD with something like an Arduino makes wiring itera: srs the dittarent (parts to share’ inform is ese esr Somponents can use to chat and work together smoothly. III. PRoczpurgs: in the context of I2C displays, the procedures typically involve the eeees £0 Set Up and use an 12C-enabled LCD or OLED display with a Sicrocontroller like Arduino. Here's a general outline of procedures: 3+ Connection Setup: Connect the 12C display to the microcontroller (e-g-, Arduino) using the SDA (data) and SCL (clock) pins. Ensure Proper power connections (VCC and GND). 2. Install Libraries the 12¢ display Leds or Download and install the necessary libraries for Common libraries include the "LiguidCrystal 12¢* for specific libraries for OLED displays. 3. Include Libraries in Code: In the Arduino Integrated Development Bnvizonnent (IDB), include the relevant libraries in your code using the #include directive. Initialize Display: Initialize the 12¢ di: of your code. This involves specify: and any other required parameters. splay in the setup section ing the display size, addressing, 5. Display Content: Write code to display the desired content on the 12¢ Gisplay. This could include text, numbers, or graphics. Upload Code: Upload the code to the microcontroller to execute the program. 7. Monitor Output: Observe the out; put on the 12¢ display. Ensure that the content is correctly display ved, and troubleshoot if’ necessary. - Rajust and Refine: Fine-tune the code as needed to achieve the desired Gisplay behavior. This may involve adjusting contrast, modifying text, or incorporating additional features, 9. Power Off and Disconnect: When finished, power off the system and disconnect the 12¢ display if necessary. Basic functions we use in code: * 1cd-begin(16,2); //Defining 16 columns and 2 rows of led display * lcd.backlight (); //To Power ON /OFF the back light 1ed.setcursor (0,0) ; //Defining position to write from first row, first column . led. setCursor (0,1) ; //Pefining position to write from second row, first colum icd.print (" write here to print"); //You can write 16 Characters per line within quotations. © 1cd.clear( //Clean the screen IV. DISCUSSION: In 16x2 LCD there are 16 pins over all if there is a back light, if there is no back light there will be 14 pins. One can power or leave the back light pins. Now in the 14 pins there are 8 data pins (7-14 or DO- D7), 2 power supply pins (162 or VSS&VDD or GND&+5v), 3rd pin for contrast control (VEE-controls how thick the characters should be shown), and 3 control pins (RS&RW&E) In the circuit, you can observe I have only taken two control pins, this gives the flexibility. The contrast bit and READ/WRITE are not often used so they can be shorted to ground. This puts LCD in highest contrast and read mode, We just need to control ENABLE and RS pins to send characters and data accordingly. ‘The connections which are done for LCD are given below: * PIN or VSS to ground © PIN2 or VDD or VCC to +5v power © PIN3 or VEE to ground (gives maximum contrast best for a beginner) © PING or RS (Register Selecticn) to PIN $0 of ESP32 © PINS or RW (Read/Write) to ground (puts LCD in read mode eases the communication for user) «PING or E (Enable) to PIN Si of ESP32 © PINII or D4 to PINS © PINI2 or DS to PING * PINI3 or D6 to PIN3 © PIN14 or D7 to PINZ Basic functions we use in code: * led.begin(16,2); //Defining 16 columns and 2 rows of lcd display * lcd-backlight (); //To Power ON /oFF the back light lcd. setCursor (0,0) ; //Pefining position to write from first row, first colum led. setCursor (0,1); //Pefining position to write from row, first column . second lcd.print(" write here to print"); //You can write 16 Characters per line within quotations. * lcd.clear(); //Clean the screen IV. DISCUSSION: In 16x2 LCD there are 16 pins over all if there is a back light, if there is no back light there will be 14 pins. One can power or leave the back light pins. Now in the 14 pine there are @ data pins (7-14 or DO- D7), 2 power supply pins (162 or VSS8VDD or GND&+5v), 3rd pin for contrast control (VEE-controls how thick the characters should be shown), and 3 control pins (RS&RHGE) . In the circuit, you can observe I have only taken two control pins, this gives the flexibility. The contrast bit and READ/WRITE are not often used so they can be shorted to ground. This puts LCD in highest contrast and read mode. We just need to control ENABLE and RS pins to send characters and data accordingly. The connections which are done for SCD are given below: * PIN or VSS to ground © PIN2 or VDD or VCC to +5v power * PIN3 or VEE to ground (gives maximum contrast best for a beginner) © PING or RS (Register Selection) to PIN S0 of ESP32 * PINS or RW (Read/Write) to ground (pute LCD in read mode eases the communication for user) PING or E (Enable) to PIN $1 of ESP32 : + Pmt or Dé to PINS + prwia or DS to PINs + pms or Ds to PINs © PIN4 or D7 to PINZ CHALLENGE ME MORE! Integrating a push button into ‘the LCD I2¢ display, the button's functionality is defined as follows: + patton the button is pressed, the system will display the following information: a. "Mechatronics" b. "Engineering" 2. Tf the button is not p a “NAME and Student No." b. ressed, the system will showcase the following data: "YOUR YEAR LEVEL" This addition enhances the LCD dis; Play, allowing users to access different sets Of information by interacting with the push button, vit. CONCLUSION AND OBSERVATION ae What did you learn in doing this activity? 2, During the activity, which factors significantly contribute to shaping your ability to successfully complete it? concuuszon: Ultrasonics Sensor with LCD Display objectives of the activity: 2. Design a functional LCD display connected to the ultrasonic sensor with an BSP32 to optimize wiring and conserve digital pins through efficient 12¢ communication. 2. Design a practical application by developing sensor interface on the Leb T2C display with the ESP32 control Expected Outcome of the activity: 1. By the end, we expect a fully working ultrasonic sensor with LCD Gispiay contzelled by 89P32, showing that we can connect things more neatly and use fewer pins. 2. The goal is to wake our £9932 easily talk to the both components, proving that we can make them communicate in a simpler wey. 3. We aim to have a display that shows important info and messages in & wtraigutforward way, proving that using 12C wakes our projects user friendly and efficient. x. INTRODUCTION ne H0-SR04 ultrasonic sensor distance measurement system utilizing an Jeiuine NO microcontroller is a versatile and efficient solution for Jueermining the distance of an object in front of it. The ultrasonic scneor sends out a sound wave and measures the time it takes for the scund wave to bounce back, allowing the system to calculate the distance epithe object. ‘The Arduino UNO microcontroller is then used to process thio distance information and display it on a convenient 16x2 LCD module. ‘This oystom can be used in a wide variety of applications such as obstacle detection, autonated door control, level detection, parking assistance, IE, BQUIPIMENTS and MATERIALS: © BsP32 © 6x2 Lop Modules © Ultrasonic Sensor = Proteus III. PROCEDURES Connect the HC-SR04 ultrasonic sensor to the Arduino Uno as vec pin to 5V follows: Trig pin to digital pin 8 Echo pin to digital pin 9 GND pin to GND Connect the 16x2 LCD module to the Arduino Uno as follows: RS pin to digital pin 7 EN pin to digital pin 6 D4 pin to digital pin 5 DS pin to digital pin 4 Dé pin to digital pin 3 7 pin to digital pin 2 vss pin to GND vop pin to 5V vo (contrast) pin to a potentiometer Define the pin numbers for the ultrasonic sensor and the LCD module in the setup function Ultrasonic ultrasonic (2, 3); LiguidCrystal led (7, 6, 5, 4, 3, 2); qn the setup function, use the begin() function to initialize the LCD module with the number of columns and rows, and the print() function to display a message on the LCD. void setup() { led.begin(16, 2); led.print ("Pistance: cm"); In the loop function, use the distanceRead() function to get the distanci in centimeters from the ultrasonic sensor, and store it in a variable. Then, use the setCursor() function to set the cursor position cn the LCD and the print () the LeD. function to display the distance on the second row of void loop() { int distance = ultrasonic.distanceRead(); lcd.setCursor (0, 1); led. print (distance) ; IV. CIRCUIT DIAGRAM ‘V. PROGRAM CODE include

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy