Week 6 - Journal

Idea & Inspiration

My project for this week is a Smart Alarm device

Description: A Warning device using 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 .

Inspiration Reference Project:

https://create.arduino.cc/projecthub/ammaratef45/detecting-obstacles-and-warning-arduino-and-ultrasonic-13e5ea

The Difference between my project and the reference project:

I used different coding system (Code Blocks) and then converted it to text, I also used a different distance limit according to my project needs.

Componenets and Softwares

Components:

1- A Buzzer

2- Ultrasonic Sensor

3-Arduino Uno

4- Jumpers

6- Adaptor 9v

7- Breadboard

8- USB to a mini USB cable

Softwares: Tinker Cad Website for simulation and Arduino IDE TO Transfer the code to the Arduino

Design Process

1- i started by googling my idea and finding a reference to find what components i need and the logic i can follow

2- then i started making the circuit on Tinkercad website and making the wiring system and the connections

3- then i started the coding using code blocks, Using (if, else condition) , first i started to set the distance variable (cm) then measuring the distance using the ultrasonic sensor input, setting the distance limit to 1 m and setting output pins values to high or low. obstacles infront of the sensor with different distances when the distance is more than 1m nothing happens (low) and no alert is produced, when the distance is less than 1m the buzzers emits the alarm sound. (high)

4- then i started the coding simulation and changed the distance for the object infront of the ultrasonic sensor

5- then i converted the blocks code to text code and copied it in Arduino IDE software and chose the port for the usb connected to arduino and started to download the code

simulation.wmv
simulation to ide.wmv

Code

Fabrication/Implementation Process

After I downloaded the code from Arduino IDE to Arduino Uno using the USB cable i started the implementation and the connections as in the diagram on tinkercad and connecting to the adaptor then i started putting obstacles infront of the sensor my different distances when the distance is more than 1m nothing happens and no alert is produced, when the distance is less than 1m the buzzers emits the alarm sound.

VID20210214102914.mp4
VID20210214103136.mp4
VID20210214102824.mp4

Overcoming Challenges and Received Support

I faced problems during the learing process through the mid-week and end of week exercises. The first Problem i faced was the way i should think before starting my code, whether it is mapping, if/else conditions or any other thinking approach in coding.

the problem was i couldn't make the exercise that controls the servo motor with a potentiometer. at first, the thinking way was to assign a rotation angle for every increase in the resistance of the potentiometer. Actually that wasn't the best way to do the coding as i would then get 180 if condition!

I googled the problem and reached a reference project and I also asked my Instructor about the best way to do it and i found it very helpful to use mapping control instead of if and else.
refernce project link:
https://create.arduino.cc/projecthub/Raushancpr/servo-motor-control-with-potentiometer-5d866f

I also turned to code libraries to get the right code blocks of the buzzer:
https://docs.google.com/presentation/d/1_75lbOuwnalkttmu0_Ym9wYfqEL4QqMbH3OGdeCnfVU/edit#slide=id.g96d71a4102_0_132

Another thing was confusing for me that was what can arduino read from different inputs? what language does it read. i asked my instructor in the end of week session and he discussed this thing with us (me and my peers), and i learned thet arduino understands the binary language 0 or 1 ( 2^0 to 2^7)