Sensors visited or revisitied

From Interaction Station Wiki
Jump to: navigation, search

short plan

10:00-11:00 we talk a bit and check in with each other / checking kits
11: 00 - 11:45 everyone chooses a sensor and gets it running
11:45 - 12:00 smoke break
12:00 - 12:30 lunch
12:30 - 14:00 work on the machines
14:00 - 14:30 everyone makes a short demo of their prototype



Analog Sensors

Analog sensors on the other hand, gives range. You connect this types of Analog sensors to Analog Input pins which is measuring the incoming voltage between 0V-5V*. Arduino converts this incoming voltage into the number between 0-1023.
Analog data is transmitted as a continuous signal, almost like a wave. In other words, an analog sensor doesn’t send a burst of 1s and 0s like digital sensors do; instead, the sensor modulates a continuous signal to transmit data.
Microcontrollers are capable of detecting binary signals: is the button pressed or not? These are digital signals. When a microcontroller is powered from five volts, it understands zero volts (0V) as a binary 0 and a five volts (5V) as a binary 1. The world however is not so simple and likes to use shades of gray. What if the signal is 2.72V? Is that a zero or a one? We often need to measure signals that vary; these are called analog signals. A 5V analog sensor may output 0.01V or 4.99V or anything inbetween. Luckily, nearly all microcontrollers have a device built into them that allows us to convert these voltages into values that we can use in a program to make a decision.
An Analog to Digital Converter (ADC) is a very useful feature that converts an analog voltage on a pin to a digital number. By converting from the analog world to the digital world, we can begin to use electronics to interface to the analog world around us.
Not every pin on a microcontroller has the ability to do analog to digital conversions. On the Arduino board, these pins have an ‘A’ in front of their label (A0 through A5) to indicate these pins can read analog voltages.
ADCs can vary greatly between microcontroller. The ADC on the Arduino is a 10-bit ADC meaning it has the ability to detect 1,024 (210) discrete analog levels. Some microcontrollers have 8-bit ADCs (28 = 256 discrete levels) and some have 16-bit ADCs (216 = 65,536 discrete levels).

The knob example (hello world)


Good read to go in detail about voltage dividers HERE

  Reads an analog input on pin 0, prints the result to the Serial Monitor.
  Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
  This example code is in the public domain.
// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  delay(1);        // delay in between reads for stability

Digital Sensors

Digital sensors are the sensors that gives 2 state (on/off, 5V/0V). You connect them to digital Pins and set them as INPUT.
Digital data consists exclusively of 0s and 1s .
For example, consider a push button switch. This is one of the simplest forms of sensors. It has two discrete values. It is on, or it is off. Other 'discrete' sensors might provide you with a binary value.
Another example of a digital sensor is an accelerometer, which sends a series of data points (speed, direction, and so on) to the Arduino. Usually digital sensors need a chip in the sensor to interpret the physical data.

Ultrasonic distance sensor

#define echoPin 9 // attach pin D9 Arduino to pin Echo of HC-SR04
#define trigPin 10 //attach pin D10 Arduino to pin Trig of HC-SR04
// defines variables
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement
void setup() {
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
  pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
  Serial.begin(9600); // // Serial Communication is starting with 9600 of baudrate speed
  Serial.println("Ultrasonic Sensor HC-SR04 Test"); // print some text in Serial Monitor
  Serial.println("with Arduino UNO R3");
void loop() {
  // Clears the trigPin condition
  digitalWrite(trigPin, LOW);
  // Sets the trigPin HIGH (ACTIVE) for 10 microseconds
  digitalWrite(trigPin, HIGH);
  digitalWrite(trigPin, LOW);
  // Reads the time the echoPin is high, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculating the distance
  distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (go and back)
  // Displays the distance on the Serial Monitor
  Serial.print("Distance: ");
  Serial.println(" cm");


More sensors:

We need to install additional libraries.

Ultrasonic sensor:

Ultrasoon Sensor - HC-SR04.jpg

Ultrasonic Sensor - HC-SR04

Light sensor:

voltage dividers

read here resistive sensors form a voltage divider together with a 10kΩ ground.

Swapping over the resistor and sensor The resistor and sensor can be swapped over to invert the action of the Voltage divider. For example an LDR has a high resistance when dark and a low resistance when brightly lit, so:
If the LDR is at the top (near +Vs), Vo will be low in the dark and high in bright light.
If the LDR is at the bottom (near 0V), Vo will be high in the dark and low in bright light.

Stretch sensor:

resistive sensors form a voltage divider together with a 10kΩ ground.

[a guide]

Capacitive Sensor-Analog:



library and tutorial

Or touch-board:

MIDI Piano.jpg


Pulse sensor(heart rate):

Pulse Sensor.jpg

library and tutorial

Hall sensor:



Temperature Sensing:


NTC temperature

[Thermistor tutorial ]

Thermistor tutorial adafruit

Soil Moisture Sensor:

SparkFun Soil Moisture Sensor

SparkFun Soil Moisture Sensor.jpg


UV sensor:


Adafruit SI1145 Breakout Board - UV index- IR -Visible Sensor.jpg

UV sensor: uv-index-sensor

Rapid assignment

Use a sensor and an output of your choice to build a machine/object that does not exist and may not fulfil any utilitarian function