Sensors: Slides and Helpful Material
by leah
Switch Example from Class

Resistive Sensor Example from Class

Arduino code:
int sensorPin = A2;
int sensorValue;
void setup()
{
Serial.begin(9600);
pinMode(A2, INPUT);
digitalWrite(A2,HIGH);
}
void loop()
{
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
delay(10);
}
Capacitive Sensor Example from Class

Download and install Paul Badger’s Capacitive Sensing Library and put it in the libraries folder in your Arduino sketchbook.
Arduino code:
#include <CapSense.h>
CapSense mySensor = CapSense(11,10); // 10M resistor between pins 11 & 10, pin 10 is sensor pin
long start;
long sensorValue;
void setup()
{
Serial.begin(9600);
}
void loop()
{
start = millis();
sensorValue = mySensor.capSense(30);
Serial.println(sensorValue); // print sensor output
delay(10); // arbitrary delay to limit data to serial port
}
[...] ended up using (with modifications) the arduino code Leah posted on the course website found here. I started by changing the pins to accommodated the lilyPad. Inspired by the exercise we did in [...]