Skip to content

11. Input devices

This week I worked with sensors which output useful measurements of different parameters.

Group Assignment

We used Karam’s Board to complete this part of the assignment.

In this section, the levelsĀ of a push button in its pressed and normal states were measured. Since the push button (which is normally open) is connected to VCC via a 10kOhm resistor, the level will be 5 V in this position (digitally high). The level will be 0 V when pressed (digitally low).

Using a digital multimeter, the value obtained is 5.05 V (digitally 1 or high) in the unpressed condition, and -1.1 mV in the pressed state (digitally 0 or low).

The same input signal was measured using an oscilloscope. The spring-loaded end (hock or clamp) of the oscilloscope probe should be connected to GND, and the pin head should be connected to the test point, which is the push button signal.

Bare in mind that the time scale is 500 ms/division and the voltage scale is 2 V/division. The signal height in the steady state is 2.5 vertical divisions, or 5V (2.5 divisions x 2 V/division). The level will descend to fit over the zero line when the button is pressed. 4 horizontal divisions of 500 milliseconds each had been spent pressing the button, totaling 2 seconds.

Individual Assignment

I used the board I designed in Electronics Design, but I added a potentiometer to it.

“A potentiometer is a manually adjustable variable resistor with 3 terminals. Two of the terminals are connected to the opposite ends of a resistive element, and the third terminal connects to a sliding contact, called a wiper, moving over the resistive element.” Source

I already had 3 pin headers, connected to VCC, GND, and an Analog pin, designed to connect the potentiometer to the board, as shown below:

To understand how a potentiometer works, I referred to this YouTube Video

The important thing to note is that the output reading of the potentiometer ranges from 0 to 1023, and this can be translated into voltage reading as shown in the below code.

Code

int PotVal;
#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1); 

void setup() {

  // initialize serial communication at 9600 bits per second:
  mySerial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {

  // read the input on analog pin 0:
  PotVal = analogRead(A1);

  // Convert (0 - 1023) to (0 - 5V):
  float voltage = PotVal * (5.0 / 1023.0);

  // print out voltage
  mySerial.println(voltage);
}

Hero Shot


Last update: June 28, 2022