Assignment 5

Input and Output Devices

This assignment is aimed at understanding the different kinds of sensors we use (directly or indirectly) in our daily lives. Along with Medha Kadian (my teammate for this assignment), we also learnt the usage of input and output devices integrated with the microcontroller, first programmed separately and later integrated to work together. Following are the details of this exercise.


1. Understanding the different types of sensors in our phone, experimenting their working and documenting our findings.

2. Connecting an input device (ultrasonic sensor) to the microcontroller and measuring the distance through proximity detection.

3. Connecting an output device (LCD Display) to the microcontroller and displaying text on it.

4. Extra credits : Combining the input and output devices to work together (Displaying the distance reading measured by ultrasonic sensor on the LCD).


1. Sensors :


1. Accelerometer : It is an electromechanical device used to measure acceleration forces. The log report is as follows:


Findings : Accelerometer is used to measure linear acceleration of the phone based on vibration, but cannot record data when orientation of phone is changed.


2. Gyroscope : It is used to measure the orientation of the phone.


Findings : Gyroscope goes one step ahead of accelerometer by recording the change in orientation of phone.


3. Magnetic sensor : It is a system to receive messages in the form of a varying magnetic field produced by a nearby electromagnet.


Findings : Gyroscope goes one step ahead of accelerometer by recording the change in orientation of phone.


4. Gravity sensor : It is a sensor which measures the acceleration effect of earth's gravity on the device enclosing the sensor.


5. Linear acceleration : It measures the acceleration effect of the device movement excluding the effect of earth's gravity on the device.


6. Orientation sensor : It provides mobile phones with a simple orientation in relation to earth's magnetic field.


7. Rotation vector : It monitors the motion of a device and can be either hardware and software based.



2. Input device :


We used ultrasonic sensor HC SR04 as an input device. It is a distance measuring devicewhich records distance based on object proximity.



The four pins of ultrasonic sensor were connected to the arduino : Vcc to 5V ; GND to GND on arduino ; Echo to Digital Pin 11 ; Trig to Digital Pin 12.

The results obtained are shown in the video below :


The code for the above results can be found here :

Arduino Code for Input device

3. Output device :

We used Liquid Crystal Display as an ouput device. This display has an LED backlight and can display two rows with upto 16 characters on each row.

The four pins of LCD I2C were connected to the arduino : Vcc to 5V ; GND to GND on arduino ; SDA on A4; SCL on A5.



The results obtained are shown in the video below :


The code for the above results can be found here :

Arduino Code for Output device

3. Integrating input and output device :

From our basic understanding of input and output devices, we now tried to integrate both of them to perform one complete task. Using Ultrasonic sensor, we calculated the distance and displayed it real-time on LCD.

The connections looked as follows :



The results obtained are shown in the video below :




The code for the above results can be found here :

Arduino Code for Input and Output device Integration

Thank You!