Week 7 - Journal

IDEA

My project for this week was to upgrade the device of the last week (week 6) which was a Smart Alarm Device through a buzzer, when objects in front of an ultrasonic sensor is closer than 1m it emits a warning tune. the distance is measured using ultrasonic sensor and both of the buzzer and the ultrasonic sensor are controlled by Arduino Uno .

The upgrade was to connect LCD to the arduino to display the measured distances by the ultrasonic sensor, when an object is closer than 1m it displays its exact distance from the sensor in cm, and when no object get closer than 1m it displays no object is detected. I also added a switch button to the circuit to turn the buzzer sound and the readings on the screen off when it is pushed.

WHAT IT MAKES?

1- Measure The Distance Of An Object Infront Of Sensor

2- Produces Alarm Tune By The Buzzer When The Distance Is Less Than 1m

3- Displays The Measured Distance On Lcd Screen And Tells When No Object Is Closer Than 1m

4- Stops Alarm Tune And The Data On Lcd When The Switch Button Is Pushed

REFERENCE PROJECTS

I googled to find inspirations and see how can i make the upgrade to my device:

Reference project link:
https://thesharanmohanblog.wordpress.com/2019/05/31/arduino-ultrasonic-sensor-hc-sr04-lcd-buzzer/?fbclid=IwAR3advjPJ8NXUHpD6HE69lbfHp0PrEf36xBPc5-6nRg4eXt7uO8rod3AM0g

Inspiration: connection of LCD to arduino to read ultrasonic sensor distances measured

Libraries installation steps and kind of libraries I need (except for LCD)

Addition: Added the feature of LCD display to upgrade my 6th week project (Smart Alarm Device) and I added a switch button to manually stop the alarm sound when pressing it.

I also made different connection of LCD (I connected SDA and SCL to A4 and A5 instead of connecting (rs, en , d4,..etc) that is used in the example and instead, I used this reference: https://create.arduino.cc/projecthub/akshayjoseph666/interface-i2c-16x2-lcd-with-arduino-uno-just-4-wires-273b24


USED COMPONENTS AND SOFTWARES

Components:

  1. A Buzzer

  2. Ultrasonic Sensor

  3. Arduino Uno

  4. qapass lcd i2c

  5. a push button

  6. Jumpers (male / female)

  7. Adaptor 9v

  8. Breadboard

  9. USB to a mini USB cable

Softwares:
I used Tinker Cad Website for simulation and Circuit Diagram and Arduino IDE TO Design / Write the code and Transfer the code to the Arduino Uno


DESIGN AND IMPLEMENTATION PROCESS

1- i started by googling my idea and finding inspirations to find how can I upgrade the device of Week 6

2- I chose the LCD as a second output and the push button as a second input (buzzer as first output component and ultrasonic sensor as first input component)

3- I started to build upon the code of the last week to add the desired features

4- I started to search on each new step I needed to write my code on Arduino IDE: first I searched on how can I connect lCD to arduino to display the measurements of the Ultrasonic sensor.

https://create.arduino.cc/projecthub/akshayjoseph666/interface-i2c-16x2-lcd-with-arduino-uno-just-4-wires-273b24

5-I uploaded the code through the USB cable to arduino and I started to make the connections for the LCD, the Buzerr to the arduino through jumpers and connected the arduino to the 9v adaptor

6- I made the test for the connection and I turned to edit my code until I had the result I wanted

7- then I started to search for the next step which was connecting the switch to the circuit

And I used this reference to understand how could it be : https://www.arduino.cc/en/tutorial/switch?fbclid=IwAR0IWti7UaN3mpqSj-P93x-vgkiUARkWrAzY6fI0Tc5cULQiBFml5JQbosk

but I found it easier to only define one state (high or low) to write from the switch pin

which is used in this reference:

https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button

8- I started compiling my code and uploaded it again to the arduino uno and made the connections of the push button and pluged in the adaptor and started my test

AND VOILA! I GOT THE REULTS I NEED

9- After this I started to make the wiring diagram for my project on tinkercad website (I didn't use it before the actual test because of the different connections I made for the LCD that differs than that in tinkercad).


Device Application.mp4
Device Application only switch.mp4

Code

WHEN I GOT STUCK!

To have my complete code I needed to search for precedents and similar project reference to see how each part of my aspired code can be made.

When I needed to know how can any thing work I starts by the diploma portal for week7 and revise if what I needed was mentioned in the tutorial videos or the code libraries for week 6 and 7 then I start googling my idea and found the reference projects that helpme in thinking process to write down my code.

References helped me:

https://create.arduino.cc/projecthub/akshayjoseph666/interface-i2c-16x2-lcd-with-arduino-uno-just-4-wires-273b24

https://www.arduino.cc/en/tutorial/switch?fbclid=IwAR0IWti7UaN3mpqSj-P93x-vgkiUARkWrAzY6fI0Tc5cULQiBFml5JQbosk

https://thesharanmohanblog.wordpress.com/2019/05/31/arduino-ultrasonic-sensor-hc-sr04-lcd-buzzer/?fbclid=IwAR3advjPJ8NXUHpD6HE69lbfHp0PrEf36xBPc5-6nRg4eXt7uO8rod3AM0g

https://create.arduino.cc/projecthub/akshayjoseph666/interface-i2c-16x2-lcd-with-arduino-uno-just-4-wires-273b24

https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button

Another thing that really helped me through this assignment was the mid week and end of week sessions, I learned how can I break the idea I want to achieve into smaller parts and to connect these parts together to reach my goal "Divide and Conquer".

And I learned how to install and include libraries in my code also from my instructor : sketch --> include library --> manage libraries --> search the library I need and install it