Created
March 23, 2017 03:07
-
-
Save ErikABengtsson/2839605629c124b90622cca57fa4d73a to your computer and use it in GitHub Desktop.
Trigger guard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Trigger guard | |
Erik Bengtsson | |
GDES-3015-001 Wearable Computing | |
OCAD University | |
Created on [22.03.2017] | |
Based on: | |
Analog Input example, Kate Hartman, https://github.com/katehartman/Make-Wearable-Electronics/blob/master/MWE_Ch06_AnalogInput/MWE_Ch06_AnalogInput.ino | |
FSR simple testing sketch, Lady Ada, https://learn.adafruit.com/force-sensitive-resistor-fsr/using-an-fsr | |
*/ | |
// initialize variable for light sensor and fsr sensor reading | |
int lightSensorValue = 0; | |
int fsrSensorValue = 0; | |
// initialize variable for light sensor pin and fsr pin | |
int lightSensorPin = A0; | |
int fsrPin = A1; | |
int fsrReading; // the analog reading from the FSR resistor divider | |
void setup() { | |
// initialize serial communication at 9600 bps | |
Serial.begin(9600); | |
} | |
void loop() { | |
// read pin and store value in a variable: | |
lightSensorValue = analogRead(lightSensorPin); | |
fsrSensorValue = analogRead(fsrPin); | |
fsrReading = analogRead(fsrPin); | |
// print the light sensor value: | |
Serial.println(lightSensorValue); | |
Serial.println(fsrSensorValue); | |
// Trying to define thresholds | |
if (fsrReading < 0) { | |
Serial.println(" - No pressure"); | |
} else if (fsrReading < 500) { | |
Serial.println(" - Light squeeze"); | |
} else if (fsrReading < 800) { | |
Serial.println(" - Medium squeeze"); | |
} else { | |
Serial.println(" - Big squeeze"); | |
} | |
// delay between readings: | |
delay(100); | |
//This code doesn't work as intended and all coding after last line was a faliure | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment