Arduino Pressure Sensitive Fabric Tutorial Code
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
#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 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