Skip to content

Week 11. Input Devices

Group Assignment: - Probe an input device(s)’s analog levels and digital signals

For this weeks group assignment we were asked to use a test equipment (multimeter, oscilloscope, etc.) to observe the signal being generated by a sensor. We decided to test an Ultrasound sensor and observe the signal using an oscilloscope.

We wrote a program in Adruino IDE where ultrasound sesor is an input device which detects the distance of the object placed infront of it.

#include <Wire.h>
#define echoPin 8             // CHANGE PIN NUMBER HERE IF YOU WANT TO USE A DIFFERENT PIN
#define trigPin 9           // CHANGE PIN NUMBER HERE IF YOU WANT TO USE A DIFFERENT PIN
long duration, distance;
void setup(){
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}
void loop(){
  // trig send a signal and when signal refelcts back and received, distance calculated 
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  distance = duration / 58.2;
  String disp = String(distance);

  Serial.print("Distance: ");
  Serial.print(disp);
  Serial.println(" cm");
  delay(1000);
}

The code was working prefectly, as we could observe the distance in the serial monitor.

alt text

Next, we set up the circuit and connected it to the oscilloscope. The probes are connected to * GND and Echo* pin of the untrasound sensor. Make sure to conncest the GND probe to GND.

alt text

We had to play around with the oscilloscope alot to get the signal shown below.

alt text alt text