DIY Sensors- Input devices

This is a collection/instructions of sensors that you can build at home with materials. Still you will need an arduino or similar board

This are the sensors you can build: - Force sensitve resistors - Shock Sensor with a speaker - Plant Moisture Sensor - Capacitive Sensing - Flex/bend Sensor - Proximity Sensor -

DIY Force Sensitive Resistor (FSR) #1

materials

Steps-fabrication

Cut your foam into the same shape as the plate or you aluminium cooking sheet

Solder one wire to each plate. Glue the three pieces together. Only glue along the outline of the FSR, otherwise it will not conduct well. For mine, I just glued the top and bottom of both plates to the foam.

Grab a multimeter and measure the resistance across your FSR. Your values will vary, but I got about 200 kiloohms at rest and 9 kiloohms when almost completely depressed. If your plates have a larger surface area, or the foam in between is thinner, these values will be smaller.

Now connect to you board like any other resistive sensor!

*You will need to try diferent values of resistor to get good readings

DIY Shock Sensor with a speaker #2

You will need to find a speaker that you are willing to sacrifice for this project. I used a small speaker from an old pair of headphones, but you can find one almost anywhere - like a musical greeting card or an old alarm clock.

Materials

Code

int shockMin = 996;  //you might need to change these
int shockMax = 1010;  //you might need to change these

void setup() {
  pinMode(11, OUTPUT);
  // Serial.begin(9600); //uncomment this to help with calibration
}

void loop() {
  int shock = analogRead(A0);
  int lightval = map(shock, shockMin, shockMax, 0, 255);
  if (lightval > 0) {
    analogWrite(11, lightval);
  }
  else {
    analogWrite(11, 0);
  }
  // Serial.println(shock); //uncomment this to help with calibration
}

Wiring

Press on the center of the speaker with your finger and it should make the led blink. If not, you will need to calibrate it in the next step. Otherwise, you can try attaching the speaker to something. Maybe you could make a drum by taping it to a paper plate? - Try using pencils as drumsticks.

Calibrate

If your led is already blinking satisfactorily, you can skip this step. Otherwise, follow these steps:

int shockMin = 996;
int shockMax = 1010;

For example, if the serial monitor reads 700 as the non-pushed state of your sensor (when it’s just sitting there),

and when you push it it goes up to 860, change the shockMax to somewhere around 900 (just a little above the sensor reading) and the shockMin to about 680. Next:

If it all goes right, the led should turn on only when you press the sensor.

DIY Plant Moisture Sensor W/ Arduino #3

This project will calculate the water content of soil around a plant by measuring the dielectric constant (the soil’s ability to transmit electricity) and will alert you with a red LED when the plant needs more water or a blue one when it has too much.

Materials

Sensor

Code

int moistPin = 0;
int moistVal = 0;
int tooDry = 150; //set low parameter for plant
int tooWet = 400; //set high parameter for plant
void setup()
{
  Serial.begin(9600);
}
void loop()
{
  moistVal = analogRead(moistPin);
  Serial.println(moistVal);
  int percent = 2.718282 * 2.718282 * (.008985 * moistVal + 0.207762); //calculate percent for probes about 1 - 1.5 inches apart
  Serial.print(percent);
  Serial.println("% Moisture ");
  if (moistVal <= tooDry) {
    digitalWrite(4, HIGH); //Red LED
    digitalWrite(3, LOW);
    digitalWrite(2, LOW);
  }
  else if (moistVal >= tooWet) {
    digitalWrite(4, LOW);
    digitalWrite(3, HIGH); //Blue LED
    digitalWrite(2, LOW);
  }
  else {
    digitalWrite(4, LOW);
    digitalWrite(3, LOW);
    digitalWrite(2, HIGH); //Green LED
  }
  delay(250);
}

Test

DIY SPONGE SENSOR #4

Link for the tutorial The sponge sensor works like a variable resister- electricity passes through a wet sponge.

As the sponge is squished more or less water lets more or less electricity pass through.

DIY Proximity Sensor #5

How to make a proximity sensor using a infrared led and infrared phototransistor.

materials

How it works

To make a simple proximity sensor, all you need is a light emitter and a light detector. The light emitter is constantly on. Whenever that light hits a nearby object, some of the light is reflected back to the detector. The closer the object is, the more light will be reflected. By measuring the output of the light detector, you can get a rough approximation of how close the object it.

This isn’t exact because the amount of reflected light also depends on the physical properties of the reflecting surface (sometimes called its reflectivity). I chose to use infrared light for this sensor because it is invisible to the human eye. So your guests won’t notice it. Also it won’t experience as much interference from the lighting in the room.

Sensor how it works

The IR LED is connected to the 5V supply with a 33 ohm series resistor. To find the appropriate resistor value for the LED use this formula:

Resistor Value = (Supply Voltage - LED Voltage) / LED Current.

In my circuit, the supply voltage is 5V. The LED is rated for 1.3V at 150 mA. This gave a resistor value of 24.7 ohm. The closest resistor that I had above this value was a 33 ohm resistor. So I used that. Be careful to not overload the resistor. A 33 ohm resistor will experience about 1/2 watt if power. If you don’t have a resistor rated for that much. You can use two 68 ohm resistors in parallel. Or you can use multiple LEDs in series to bring down the voltage across the resistor.

The emitter of the phototransistor is connected to ground. The collector is wired to a 10 kohm resistor that is connected to 5V. An additional wire is connected to the collector to act as an output pin for the sensor. I soldered the sensor components together on a small piece of perf board. I added three pins to connect the sensor to the signal processor. To ensure that only reflected light is detected by the phototransistor, it is important to add a light barrier between the LED and the phototransistor. The most effective way to do this is to put a black piece of heat shrink tubing around the phototransistor. This also helps to make the sensor more directional.

Code

In most cases you will use a microcontroller such as an Arduino to monitor the signal from the sensor. To do this, connect the ground terminal from the sensor to the GND pin on the Arduino. Connect the 5V wire from the sensor to either the 5V pin or a digital output pin set to HIGH. Then connect the signal wire from the sensor to an analog input pin on the Arduino.

// Example Code
int InputPin = 0;      // analog pin 0 is the input pin
int OutputPin = 1;   // digital pin 1 is the output pin
int val = 0;              // variable to store the value read

void setup()
{
pinMode(OutputPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
  digitalWrite(OutputPin, LOW);    // sets the output pin initially to LOW
  val = analogRead(InputPin);        // read the input pin 0 to 1023
  if (val < 800)                              // if sensor value is below threshold set output HIGH
{
  digitalWrite(OutputPin, HIGH);    // sets output pin HIGH to activate special effects
delay(1000);                  // waits for a second
}
}

The AnalogRead function measures the voltage of the signal coming from the sensor. When the voltage drops below a set threshold, the Arduino activates the your special effects. Here is an quick example of the code that you could use.

DIY Flex/bend Sensor #6

Build a flex/bend sensor that is compatible with an arduino board and does not require static bags or anything unusual, you can make this right now from things you have around the house.

LINK FOR THE TUTORIAL