Login Shopping cart Checkout Distributors Tutorials  


Search



Join our mail list

Email:

 Subscribe
 Unsubscribe

This is one of the ways you can connect one pressure sensitive fabric switches to an Arduino. Our pressure sensitive fabric switches work as digital switches (ON/OFF). Any schematic you can find to connect a switch to Arduino works fine, with the only exception that you will have to increase the debouncing time.

What you need is:

- Arduino
- a pressure sensitive fabric switch
- breadboard
- wires
- an LED
- a 10 kOhm resistor
- a 1 kOhm resistor
- power supply for Arduino, or a PC with a USB port


This schematic uses two resistors, a pull down 10 KOhm resistor and a 1 kOhm resistor.

Start by placing your breadboard near your Arduino and connect positive and negative breadboard buses to Arduino's 5V and ground, GND

connect 5V and GND


Then place the 10 kOhm resistor between the GND and another row on the breadboard as shown here:

10 kOhm 


Now place the other resistor as in the following picture.

1 kOhm


It is now time to connect our circuit to Arduino's pin 10. We connect pin 10 because in our sketch it is the input that the Arduino will read.


connect input 10

Connect now 5V to one of the rows

connect 5V

and one of the wires of the fabric switch to that row

connect switch

and the other wire coming from the switch to the row where the 1k resistor has been placed

connect switch

Place the LED with the longer leg in pin 13 of the Arduino and the shortest one in the GND pin. We connect pin 13 because in our sketch pin 13 has been defined as output.

LED

Check that you have done all connections properly and then you can connect Arduino to your PC, copy and transfer the following sketch to Arduino.

 
*
 * Each time the input pin goes from LOW to HIGH (e.g. because of a push-button
 * press), the output pin is toggled from LOW to HIGH or HIGH to LOW.  There's
 * a minimum delay between toggles to debounce the circuit (i.e. to ignore
 * noise). 
 * FOR FABRIC SWITCHES DEBOUNCE TIME SET AT 500 MSEC
 *
 * NOTE: INPUT PIN = 10, OUTPUT PIN = 13
*
* David A. Mellis
* 21 November 2006
*/ 

int inPin = 10;         // the number of the input pin
int outPin = 13;       // the number of the output pin

int state = HIGH;      // the current state of the output pin
int reading;           // the current reading from the input pin
int previous = LOW;    // the previous reading from the input pin

// the follow variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long time = 0;         // the last time the output pin was toggled
long debounce = 500;   // the debounce time, increase if the output flickers

void setup()
{
  pinMode(inPin, INPUT);
  pinMode(outPin, OUTPUT);
}

void loop()
{
  reading = digitalRead(inPin);

  // if the input just went from LOW and HIGH and we've waited long enough
  // to ignore any noise on the circuit, toggle the output pin and remember
  // the time
  if (reading == HIGH && previous == LOW && millis() - time > debounce) {
    if (state == HIGH)
      state = LOW;
    else
      state = HIGH;

    time = millis();   
  }

  digitalWrite(outPin, state);

  previous = reading;
}
 

after you finished transferring the LED on pin 13 should go on.



power on

press the fabric switch and you will see the LED going off and on every time you press it (toggle mode). You can connect a small relay to the output and control a light.

project finished
 

Currency

 


Shopping cart

There are no products in your shopping cart.