11. Input devices

An input device is an equipment/Component used to provide data and control signals to an information processing system such as a Micro Controller. Examples of input devices include Sensors, Cameras etc.

Sensors : A sensor is a transducer whose purpose is to detect some characteristic of its environments. It detects events or changes in quantities and provides a corresponding output, generally as an electrical or optical signal. Transducers are measurement devices used to change one kind of energy to another. Energy may include electrical, mechanical, electromagnetic, chemical, acoustic, and thermal energy.

input

Devices which perform an “Input” function are commonly called Sensors because they “sense” a physical change in some characteristic that changes in response to some excitation, for example, heat or force and convert that into an electrical signal. Devices which perform an “Output” function are generally called Actuators and are used to control some external device, for example, movement or sound.

input

The Board

inputdevices

input

inputdevices

inputdevices

inputdevices

inputdevices

inputdevices

inputdevices

Programming

inputdevices

MISO-MISO
VCC-VPROG
SCK-SCK
MOSI-MOSI
RST-RST
GND-GND

Touch Sensor

#define ctsPin A1  // define pin for touch input
int ledPin = 13; // define pin for LED output

void setup()
{
  pinMode(ledPin, OUTPUT); // define input
  pinMode(ctsPin, INPUT); // define output
}

void loop()
{
  int ctsValue = digitalRead(ctsPin); // read input value
  if (ctsValue == HIGH) // input condition
  {
    digitalWrite(ledPin, HIGH); // output 1

  }
  else // when the above condition is not fulfilled
  {
    digitalWrite(ledPin, LOW); // output 2
  }
  delay(0.9);
}

The Video

Ultrasonic Sensor

(Note : I started with the code on this page and modified it further for the desired application)

const int trigPin = A2;
const int echoPin = A3; // defining the pins

long duration;

int distance; // defining variables

void setup()

{
  pinMode(13, OUTPUT);
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
  Serial.begin(9600); // Starts the serial communication
}
void loop() 
{
  digitalWrite(trigPin, LOW); // Clears the trigPin
  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH); //Sets the trigPin on HIGH state for 10 micro seconds
  delayMicroseconds(10);

  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds
  distance = duration * 0.034 / 2; // Calculating the distance
  Serial.print("Distance: ");
  Serial.println(distance); // Prints the distance on the Serial Monitor

  if (distance < 100)
  {
    digitalWrite(13, HIGH);
  }
  else
  {
    digitalWrite(13, LOW);
  }
}
Video

Group Work

The Group Assignment was to probe an input device’s analog levels and digital signals. The group page can be found here