9. Input Devices¶
Objectives of the Week¶
- Understand the concept of input devices
- Practice basic circuitry incorporating input devices
- Demonstrate workflows used in sensing something with input device(s) and MCU board
Schedule¶
Wednesday, March 18th - Input Devices
Thursday, March 19th : Basics of input devices and measurement
Friday, March 20th : Interesting input devices
Assingments¶
Group assignment:¶
- Probe an input device(s)’s analog levels and digital signals (As a minimum, you should demonstrate the use of a multimeter and an oscilloscope.)
- Document your work on the group work page and reflect on your individual page what you learned
Individual assignment:¶
- Measure something: add a sensor to a microcontroller board that you have designed and read it.
Class Notes and Work¶
This week we learned about input devices and how to trouble shoot.
- We stared with a simple circuit that incldued a potenciometer and fixed resitence. Using a multmeter, we could see the realtive resistence of the potenciometer change as we turned the dial.
- Our second circuit included a flame sensor and fixed resistance. We connected this circuit to an oscilloscope to visualise the change in resistence across the flame sensor as we exposed it to heat.
Independant Work¶
As part of the individual assigment I built a circuit which utalized capacitive touch.
The code¶
The code for this was interesting because, when the sensor is touched, each light turns on after a different delay. It also reads the temerature sensor from the Barduino board are returns a human readible value. There were two primary challenges assocaited with creating this code.
Challenge 1: The temperature sensor requires a special library. In order to return human readible values I downloaded the library “Temerature_LM75” and loaded the library by including
#include <Temperature_LM75_Derived.h>
Generic_LM75 temperature;
Challenge 2: To turn the lights on when the sensor was touched, I created a threshold. When the voltage registered by the capacitive touch device reached the threshold it triggered the light to turn on.
long threshold = 60000;
.
.
.
void loop() {
long signal = touchRead(touchPin);
The full source code can be seen here.
Code
/*
Read the temperature from an LM75-derived temperature sensor, and display it
in Celcius every 250ms. Any LM75-derived temperature should work.
*/
// The Generic_LM75 class will provide 9-bit (±0.5°C) temperature for any
// LM75-derived sensor. More specific classes may provide better resolution.
#include <Temperature_LM75_Derived.h>
Generic_LM75 temperature;
int touchPin = 12;
int redPin = 13;
int greenPin = 14;
int bluePin = 15;
int singleyellowPin = 11;
int singleredPin = 10;
long threshold = 60000;
void setup() {
Serial.begin(115200);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(singleyellowPin, OUTPUT);
pinMode(singleredPin, OUTPUT);
while(!Serial) {}
Wire.begin();
}
void loop() {
long signal = touchRead(touchPin);
if (signal > threshold) {
digitalWrite(redPin, LOW);
digitalWrite(greenPin, HIGH);
digitalWrite(bluePin, HIGH);
Serial.println("touched");
delay(350);
digitalWrite(singleyellowPin, HIGH);
delay(350);
digitalWrite(singleredPin, HIGH);
} else {
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, LOW);
digitalWrite(bluePin, LOW);
Serial.println("not touched");
delay(350);
digitalWrite(singleyellowPin, LOW);
delay(350);
digitalWrite(singleredPin, LOW);
}
Serial.print("Temperature = ");
Serial.print(temperature.readTemperatureC());
Serial.println(" C");
delay(100);
}
Outstanding Items¶
- I need to incorporate the input sensors into a