Created
October 28, 2014 16:00
-
-
Save christiangenco/9b0b2232e9ccb2f532d7 to your computer and use it in GitHub Desktop.
An IO device for your feet: http://christian.gen.co/walkie-sockie/
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
// WalkieSockie | |
// Christian Genco: @cgenco | |
// An alternate input/output device for the feet | |
// pins | |
static int pressurePin = A5, vibratorPin = 11; | |
// thresholds | |
static int pressureLow = 0, pressureHigh = 1000, | |
vibeLow = 0, vibeHigh = 255; | |
boolean smooth = true; | |
static int threshold = pressureHigh/2; | |
void setup() { | |
vibratorPin = 9; | |
pinMode(pressurePin, INPUT); | |
pinMode(vibratorPin, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
int sensorValue = analogRead(pressurePin); | |
if(smooth){ | |
analogWrite(vibratorPin, map(sensorValue, pressureLow, pressureHigh, vibeLow, vibeHigh)); | |
}else{ | |
boolean crossedThreshold = sensorValue > threshold; | |
digitalWrite(vibratorPin, crossedThreshold ? 1 : 0); | |
} | |
Serial.println(sensorValue); | |
// Serial.println(map(sensorValue, pressureLow, pressureHigh, 0, 255)); | |
// Serial.println(sensorValue); | |
delay(100); // delay in between reads for stability | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment