Both sides previous revision Previous revision | |||
fabricademy2017:students:nuria.robles:week_5 [2018/01/31 13:16] nuriafablab_gmail.com |
fabricademy2017:students:nuria.robles:week_5 [2018/05/12 00:51] (current) nuriafablab_gmail.com |
||
---|---|---|---|
Line 32: | Line 32: | ||
|{{:fabricademy2017:students:nuria.robles:week5_e-textiles_wearables:ass_2.png?nolink&366x300}} |{{:fabricademy2017:students:nuria.robles:week5_e-textiles_wearables:13_img_9623.jpg?nolink&399x300|13_img_9623.jpg}} | | |{{:fabricademy2017:students:nuria.robles:week5_e-textiles_wearables:ass_2.png?nolink&366x300}} |{{:fabricademy2017:students:nuria.robles:week5_e-textiles_wearables:13_img_9623.jpg?nolink&399x300|13_img_9623.jpg}} | | ||
+ | |||
+ | The arduino code I used is: | ||
+ | |||
+ | <code> | ||
+ | |||
+ | /* | ||
+ | CODE for the Fabricademy e-textile sensor swatch | ||
+ | first built for the Fabricademy 2017 | ||
+ | Hannah Perner-Wilson and Mika Satomi, KOBAKANT | ||
+ | */ | ||
+ | |||
+ | #define sensorPin 3 | ||
+ | //#define speakerPin 2 (not tested yet) | ||
+ | #define ledPin 0 | ||
+ | |||
+ | int sensorValue = 0; | ||
+ | //int noiseFrequency = 0; (not tested yet) | ||
+ | int ledBrightness = 0; | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | pinMode(sensorPin, INPUT); // use digital pin number here | ||
+ | //pinMode(speakerPin, OUTPUT);(not tested yet) | ||
+ | pinMode(ledPin, OUTPUT); | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | sensorValue = analogRead(sensorPin); // use analog pin number here | ||
+ | |||
+ | /*(not tested yet) | ||
+ | // MAKE SOUND: | ||
+ | if(sensorValue <900){ | ||
+ | noiseFrequency = map(sensorValue, 0, 1023, 100, 10000); | ||
+ | noise (speakerPin, noiseFrequency); | ||
+ | } | ||
+ | */ (not tested yet) | ||
+ | |||
+ | // FADE LED: | ||
+ | ledBrightness = map(sensorValue, 0, 1023, 0, 255); | ||
+ | analogWrite(ledPin, ledBrightness); | ||
+ | } | ||
+ | |||
+ | /* (not tested yet) | ||
+ | |||
+ | // MAKE SOUND ON THE ATTINY WITHOUT THE SOUND LIBRARY: | ||
+ | void noise (unsigned char noisePin, int frequencyInHertz) { | ||
+ | long delayAmount = (long)(1000000 / frequencyInHertz); | ||
+ | digitalWrite(noisePin, HIGH); | ||
+ | delayMicroseconds(delayAmount); | ||
+ | digitalWrite(noisePin, LOW); | ||
+ | delayMicroseconds(delayAmount); | ||
+ | |||
+ | */ (not tested yet) | ||
+ | } | ||
+ | </code> | ||
The last part I wanted to do is to connect the buzzer and change the sound with the pressure of the fingers over the sensor but I run off time | The last part I wanted to do is to connect the buzzer and change the sound with the pressure of the fingers over the sensor but I run off time |