/*
* 09/26/07
* Tangible User Interfaces
* Lab 4 Sensors: Force sensitive resistors and photocells
* Eun Kyoung Choe
*/
// variables for input pin and control LED
int analogInput = 3;
int LEDpin1 = 13;
int LEDpin2 = 12;
int LEDpin3 = 11;
// variable to store the value
int value = 0;
// a threshold to decide when the LED turns on
int threshold = 512;
void setup(){
// declaration of pin modes
pinMode(analogInput, INPUT);
pinMode(LEDpin1, OUTPUT);
pinMode(LEDpin2, OUTPUT);
pinMode(LEDpin3, OUTPUT);
// begin sending over serial port
beginSerial(9600);
}
void loop(){
// read the value on analog input
value = analogRead(analogInput);
// if value greater than threshold turn on LED
if (value < threshold){
digitalWrite(LEDpin1, LOW);
digitalWrite(LEDpin2, LOW);
digitalWrite(LEDpin3, LOW);
}
else{
digitalWrite(LEDpin1, HIGH);
digitalWrite(LEDpin2, HIGH);
digitalWrite(LEDpin3, HIGH);
}
// print out value over the serial port
printInteger(value);
// and a signal that serves as seperator between two values
printByte(10);
// wait for a bit to not overload the port
delay(10);
}