Input Devices
Soft textile sensors
Following my learnings from Fabricademy and Wearable Electronics course at Aalto, I handcrafted two soft sensors. The switch uses simple conductive yarn to make or break connection between layers as they are pressed together. The soft pressure sensor uses Velostat - a plastic pressure-sensitive conductive sheet. The resistance in Velostat piece varies according to pressure applied to it and value may be measured.
soft tactile switch
soft pressure sensor
Circuit
Design
I placed a header to make attaching hand-crafted sensors easier. I can then add resistors to the crocodile clips according to resistance needs later on.Fabrication
When fabricating the board, one of the tracks didn't mill deep enough to remove the copper layer entirely. Luckily, the missing part was along straight line. Willing to try to rescue the board, I tried to carve the copper out with a sharp ended scalpel tool along a ruler to maker sure it was straight. It worked
Testing
I tested the board with both an off-shelf pressure sensor and the hand-crafted one. Both worked similarly
int LED_R_PIN = 2;
int LED_G_PIN = 3;
int LED_B_PIN = 4;
int POT_PIN = 5;
int BUTTON_PIN = 9;
int hue = 0;
bool ledOn = false;
void setup() {
pinMode(LED_R_PIN, OUTPUT);
pinMode(LED_G_PIN, OUTPUT);
pinMode(LED_B_PIN, OUTPUT);
pinMode(POT_PIN, INPUT);
pinMode(BUTTON_PIN, INPUT_PULLUP);
Serial.begin(115200);
}
void loop() {
// Read the potentiometer value
int pot_value = analogRead(POT_PIN);
// Map the potentiometer value to a range of 0-255
hue = map(pot_value, 200, 4095, 0, 255);
Serial.println(pot_value);
delay(40);
// Check if the button is pressed
int btnReading = digitalRead(BUTTON_PIN);
if (btnReading) {
ledOn = !ledOn; // Toggle the button state
while(digitalRead(BUTTON_PIN)) {
delay(10); // Debouncing delay
}
}
// If the button is pressed, turn on the LED, otherwise turn it off
if (ledOn) {
setColor(hue);
} else {
digitalWrite(LED_R_PIN, HIGH);
digitalWrite(LED_G_PIN, HIGH);
digitalWrite(LED_B_PIN, HIGH);
}
}
void setColor(int hue) {
// Calculate the RGB values based on the hue
int red_value = cos((hue + 120) * 0.01745) * 127 + 128;
int green_value = cos(hue * 0.01745) * 127 + 128;
int blue_value = cos((hue - 120) * 0.01745) * 127 + 128;
// Set the LED colors
analogWrite(LED_R_PIN, red_value);
analogWrite(LED_G_PIN, green_value);
analogWrite(LED_B_PIN, blue_value);
}