//Force Sensor to Light Fade
//turn on the serial statements to DEBUG
//add in mapping statements to make for a better response
int ForceSensePin = A2;
int ledPin = 9;
int ForceSensorValue;
int ForceSensePin2 = A0;
int ledPin2 = 8;
int ForceSensorValue2;
int buzzerPin = 4; // Connect Buzzer to Pin 4
long buzzerFreq; // The frequency to buzz the buzzer
// You can experiment with these values:
long BUZZ_FREQ_MAX = 24000; // Maximum frequency for the buzzer
// keep increasing BUZZ_FREQ_MAX until you get the full range
long PR_MAX = 1023; // Maximum value for the forceResistor
void setup() {
pinMode (ledPin, OUTPUT);
pinMode (ledPin2, OUTPUT);
}
void loop() {
ForceSensorValue = analogRead(ForceSensePin);
analogWrite(ledPin, ForceSensorValue);
// apply the calibration to the sensor reading
ForceSensorValue = map(ForceSensorValue, 0, 100, 0, 255);
// in case the sensor value is outside the range seen during calibration
ForceSensorValue = constrain(ForceSensorValue, 0, 255);
ForceSensorValue2 = analogRead(ForceSensePin2);
analogWrite(ledPin2, ForceSensorValue2);
// apply the calibration to the sensor reading
ForceSensorValue2 = map(ForceSensorValue2, 0, 100, 0, 255);
// in case the sensor value is outside the range seen during calibration
ForceSensorValue2 = constrain(ForceSensorValue2, 0, 255);
Serial.println(ForceSensorValue);
}