Pressure sensor with antistatic foam

From LVL1
Revision as of 00:31, 11 February 2011 by Bpwagner (talk | contribs) (→‎How to)
Jump to navigation Jump to search

Introduction

Pressure Sensor with antistatic foam

Here we are building our own pressure sensor out of antistatic foam, 2 pennies and some electrical tape.

Components Needed

  • Freeduino or Arduino or clone
  • USB cable for Freeduino
  • Freeduino development software - download here!
  • Solderless Breadboard
  • Hookup wire 22gauge solid
  • 2 pennies
  • some sandpaper
  • 1 sq in of antistatic foam (used to pack chips - the black stuff!)
  • 1 resistor 1K to 10K
  • electrical tape

How to

  1. Use the sandpaper to make your pennies shine bright copper
  2. Solder a 8" wire to each penny - This is kind of difficult, you will need to heat up the penny and use lots of solder. Make sure the wire is stuck on well.
  3. Sandwich the antistatic foam between the pennies
  4. Wrap with some electrical tape
  5. The thing you just made is a pressure sensor and it works like a resistor. Use it in a voltage divider circuit (like the light sensor and the thermistor) to measure the pressure when you squeeze the two pennies together.

Schematic

Fritzing

Code

First, you can test this circuit easily without a LCD screen using the example arduino script "AnalongInSerial" Upload and run the script. Then turn on the serial monitor in the Arduino IDE (ctrl+shift+M) and squeeze the pressure sensor!

//This code builds upon Inning 5 by
//showing the value of a pot on analog 0
//bpw 5/11/10


// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

int inPin = 2;   // choose the input pin (for a pushbutton)
int val = 0;     // variable for reading the pin status

int potpin = 0;  // analog pin 0
int potval = 0;     // variable for reading the pin status

int pcpin = 1;  // analog pin 1 - photocell
int pcval = 0;     // variable for reading the pin status

int thpin = 2;  // analog pin 2 - thermistor
int thval = 0;     // variable for reading the pin status

void setup() {
  // set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  //lcd.print("hello, world!");
  
  pinMode(inPin, INPUT);    // declare pushbutton as input

}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
  
  lcd.setCursor(6, 1);  //col 6, row 1
  //code for button pressed!
  val = digitalRead(inPin);  // read input value
  if (val == LOW) {         // check if the input is HIGH (button released)
    lcd.print("DOWN");
  } else {
    lcd.print("UP  ");
  }
  
  //read the pot - values are 0..1023
  lcd.setCursor(12, 1);  //col 12, row 1
  lcd.print("    ");
  potval = analogRead(potpin);    // read the value from the (center lead of ) potentiometer connected to potpin
  lcd.setCursor(12, 1);  //col 12, row 1
  lcd.print(potval);
  
  //read the photocell - values are 0..1023
  lcd.setCursor(0, 0);  //col 12, row 1
  lcd.print("PC:");
  pcval = analogRead(pcpin);    // read the value from the photocell circuit
  lcd.print(pcval);
  
    //read the thermistor - values are 0..1023
  lcd.print("  Th:");
  thval = analogRead(thpin);    // read the value from the thermistor circuit
  lcd.print(thval);
  
}

Troubleshooting