Both sides previous revision Previous revision | Next revision Both sides next revision | ||
fabricademy2017:students:julie.taris:class9-e-textiles-wearables2 [2018/06/25 20:56] julie_taris |
fabricademy2017:students:julie.taris:class9-e-textiles-wearables2 [2018/06/25 20:58] julie_taris |
||
---|---|---|---|
Line 181: | Line 181: | ||
[http://www.instructables.com/id/Connecting-a-textile-analog-sensor-to-Arduino/|Connecting a Textile Analog Sensor to Arduino]] | [http://www.instructables.com/id/Connecting-a-textile-analog-sensor-to-Arduino/|Connecting a Textile Analog Sensor to Arduino]] | ||
+ | |||
+ | <code> | ||
+ | int softPot = 0; // this line selects the input pin a0 for the sensor | ||
+ | int ledPin = 13; // this line selects the pin 13 for the LED output | ||
+ | int tempPot = 0; // variable to store the value coming from the sensor | ||
+ | |||
+ | void setup() { | ||
+ | // this line declares the ledPin as an OUTPUT: | ||
+ | pinMode(ledPin, OUTPUT); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // read the value from the sensor and store the value in the variable tempPot | ||
+ | tempPot = analogRead(softPot); | ||
+ | // it turns the LED on | ||
+ | digitalWrite(ledPin, HIGH); | ||
+ | // stop the program for milliseconds: | ||
+ | delay(tempPot); | ||
+ | // turn the LED off: | ||
+ | digitalWrite(ledPin, LOW); | ||
+ | // stop the program for for milliseconds: | ||
+ | delay(tempPot); | ||
+ | } | ||
+ | </code> | ||
{{vimeo>245700846?medium}} | {{vimeo>245700846?medium}} |