Input Devices

Tasks of the week

Group Assignment

  • Measure the analog levels and digital signals in an input device.
  • Individual Assignment.

  • Measure something: Add a sensor to a microcontroller board that you have designed and read it.
  • Group Task

    In group assignment of this week, we have to measure analog levels and digital signals in an input device.

    Measuring Analog Levels of Phototransistor

    SFH 320 Silicon NPN Phototransistor is used by one of our group member in individual task in which the circuit is detecting light and displays result of light intensity on bar using python. So as the group assignment we measured the resistance of this component which is changed when we increase or decrease the intensity of lights on it. The resistance is measured by Digital Multimeter. We observe that at one instance when we increase the intensity of light resistance decreases and when we decrease intensity of light resistance increases.

    Measuring resistance with low intensity of light

    Measuring resistance with high intensity of light

    Detecting Digital Signals in UltraSonic Sensor

    HC SR-04 Ultrasonic sensor is used by one of our group member in his individual task of this week. We detect the change in digital signal in Oscilloscope using arduino UNO. A sensor is connected with arduino and the pin of Echo is connected with Oscilloscope. Arduino is program to detect obstacle in front of Ultrasonic sensor (a code is attached with files), when an obstacle is present in front of Ultrasonic sensor we found change in wave in oscilloscope.

    A digital signal without obstacle front of ultrasonic sensor

    A digital signal with obstacle front of ultrasonic sensor

    Individual Task

    For Input devices, I choose to use ultrasonic sensor. Ultrasonic sensor is a device which is used to measure distance to an object. This works by sending out a wave which comes back by striking an object, it measure the time elapsed from generating of the wave to bounce back. This way it measures distance from the origin position of the sensor to the object. It follows the given below formula to calculate the distance.
    Distance = [{(Speed of sound)*(Time taken)}/2]
    For more about ultrasonic sensor, refer this site.

    I sketched its pin diagram on a page shown below, I connected basic necessary components to the IC, like:

    At reset pin (pin no.4 of attiny44), we have to use a pull up resistor of 10K to 20K ohm as mentioned in the datasheet of attiny44. I used 10K ohm value resistor for this purpose. Below snapshot is for further clarification about pull up resistor.

    Then, I designed it on 'eagle', added and connected required components on 'schematic' part, and, in 'board' part I shape it to its final look.

    The size of the board is 1.7/a.5 inches.

    monochrome png images are ready for generating .rml files for traces, drills, and cut.

    Generating .rml files from Fab Modules.

    by clicking on 'save' tab, .rml file will download automatically for traces of the board.

    by clicking on 'save' tab, .rml file will download automatically for drills of the board.

    by clicking on 'save' tab, .rml file will download automatically for boundary/outline of the board.

    board is milled and solderd.

    After complete soldering of the components to the board, the next step is to up the circuit by burning bootloader through an ISP programmer. So, here I did it successfully.

    Done with burning bootloader. The above blinked LED is not concerned with burning bootloader of the board, it is power LED directly connected to VCC and Ground with a resistor for limiting the current for LED.

    Here is the code, which uploaded and then sensor gives value in serial monitor as I changed the object distance from the sensor. The unit of distance is in centimeters here in this case.

    #include "SoftwareSerial.h"
    // defines pins numbers
    SoftwareSerial mySerial(4, 6); /* RX:D3, TX:D2 */
    const int trigPin = 2;
    const int echoPin = 3;
    // defines variables
    long duration;
    int distance;
    void setup() {
    pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
    pinMode(echoPin, INPUT); // Sets the echoPin as an Input
    mySerial.begin(9600); // Starts the serial communication
    void loop() {
    // Clears the trigPin
    digitalWrite(trigPin, LOW);
    // Sets the trigPin on HIGH state for 10 micro seconds
    digitalWrite(trigPin, HIGH);
    digitalWrite(trigPin, LOW);
    // Reads the echoPin, returns the sound wave travel time in microseconds
    duration = pulseIn(echoPin, HIGH);
    // Calculating the distance
    distance= duration*0.039/2; // Here the displayed distance is in centimeters cm
    // Prints the distance on the Serial Monitor
    mySerial.print("Distance: ");

    Code compiled and uploaded successfully

    Serial monitor of the arduino is indicating the distance of the object from the sensor.

    As the object comes near to the ultrasonic sensor, it displays the distance in centimeters accordingly.

    Download all files from here

    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.