Soft Switch Documentation
Materials:
Fabric pushbutton
Fabric pressure sensor
Code:
The code for the pushbutton is located in “File” –> “Examples” –> “Digital” –> “Button” in Arduino.
The code for the pressure sensor is a very simple variation of the AnalogInput example code:
/*
Liza Stark
Fabric Pressure Sensor
March 7, 2011
This is a variation of the AnalogInput code that can be found on the Arduino website.
http://arduino.cc/en/Tutorial/AnalogInput
*/
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 11; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
//pinMode(sensorPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
analogWrite(ledPin,sensorValue);
// write the value of the sensor to the ledPin using PWM
}