Input Devices
Introduction
In this week lab the task is to build one circuit board with input device. there are many input devices some we have used before such as switches others we did not such as ultrasonic, magnetic sensors, distance sensors, flex sensors ...etc. I have picked the ultrasonic sensor. in my final project I might use switches or ultrasonic sensor depending on how i decide the way it perform. and as i had done before the switch i thought i might install ultrasonic sensor and check the way it works.
About Ultrasonic Sensor
The module i am using is Ultrasonic Ranging Module HC - SR04. It has four wire direct connection:
1- 5V Supply.
2- Trigger Pulse Input.
3- Echo Pulse Output.
4- 0V Ground.

Working Voltage DC 5 V <
Working Current 15mA
Working Frequency 40Hz
Max Range 4m
Min Range 2cm
MeasuringAngle 15 degree
Trigger Input Signal 10uS TTL pulse
Echo Output Signal Input TTL lever signal and the r ange in proportion
Dimension 45*20*15mm "
Link to Ultrasonic HC - SR04 Data Sheet
Preparing the Design

I used eagle to design the circuit board as shown above with additional thing. in order to show that the sensor is working i installed a LED. then i created the BRD design and printed out the circuit board "all details of creating the schematic design, BRD design and printing the circuit boards are mentioned in earlier weeks.


Soldring the circuit board
I think i am familiar with soldering, it was quite fast. after finishing soldering all the elements i fixed 1x4 pins on the circuit board and soldered cables to connect my circuit board with the ultrasonic sensor.
programming the circuit board
There are 2 ways to program the ultrasonic sensors. the first one is to define trigger and echo elements and create formulas to set the values and timing. the second one, is to use a library of ultrasonic. therefore i downloaded the library -> extracted the folder and copy paste the folder in Arduino/libraries folder. but the library did not work. i read some forums on the net and noticed some libraries are not compatible with my arduino version. so i downloaded anther library and it worked. below is the code used for testing the circuit board.

Downloaded files
Schematic File
Board File
Arduino File
Ultrasonic HC - SR04 Data Sheet