Created
October 9, 2016 18:15
-
-
Save sshadmand/34a2f73e48a731c3c2e86b2171d6c41e to your computer and use it in GitHub Desktop.
Arduino Pressure Sensitive Fabric Tutorial Code
This file contains hidden or 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
#include <math.h> | |
int myPin = 0; | |
int touching = false; | |
int touchingCount = 0; | |
void setup() { | |
Serial.begin(9600); | |
} | |
// the loop function runs over and over again forever | |
void loop() { | |
int sensorValue = analogRead(myPin); | |
String amount = "Start Touch"; | |
if (sensorValue > 90) { | |
touching = true; | |
touchingCount++; | |
} else { | |
touching = false; | |
touchingCount = 0; | |
} | |
if (touching && touchingCount < 20) { | |
amount = "Tap"; | |
} else if (touching) { | |
amount = "Hold"; | |
} | |
if (sensorValue < 90) { | |
// Serial.println("Not touched"); | |
} else if (sensorValue < 120) { | |
Serial.println("Light " + amount); | |
} else if (sensorValue < 160) { | |
Serial.println("Strong " + amount); | |
} else if (sensorValue < 190) { | |
Serial.println("Hard " + amount); | |
} | |
} |
This file contains hidden or 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
#include <math.h> | |
int myPin = 0; | |
void setup() { | |
Serial.begin(9600); | |
} | |
// the loop function runs over and over again forever | |
void loop() { | |
int sensorValue = analogRead(myPin); | |
Serial.println(sensorValue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment