====== ====== E textiles & wearables II ====== ====== ==== Theme : Sound and electronics ==== **__Idea : create an instrument, Theremin.__ ** The [[https://en.wikipedia.org/wiki/Theremin|Theremin]] is an electronic instrument creating sound with no physical contact. there is easier way to make sound with a sensor light and a piezo. === === ---- I follow this [[http://www.dummies.com/computers/arduino/how-to-make-an-instrument-with-the-arduino/|tutorial]] from John Nussey to start. tools used : * Arduino uno * Breadboard * Piezo buzzer * Light sensor * 2 resistors 0.22 * jump wires == _ == == step 1 : == schema : The light sensor is connected to analog 0 on one side and 5V on the other. the 2 resistors are connected between analog 0 and ground. {{:fabricademy2017:students:pauline_bianchi:electronics_ii:381399.image1.jpg?nolink&400x400|381399.image1.jpg}} Circuit : {{:fabricademy2017:students:pauline_bianchi:electronics_ii:381398.image0.jpg?nolink&400x559|381398.image0.jpg}} I did the Circuit with two resistors of 0.22 to have more or less the equivalent of a 4.7K resistor. {{:fabricademy2017:students:pauline_bianchi:electronics_ii:schema_lightsensor_2resistors.png?nolink&400x308}} _ First, to understand the circuit and to know if a sound was going to be produce by the piezo, I connected everything on a breadboard. I tried first with this piezo : {{:fabricademy2017:students:pauline_bianchi:electronics_ii:piezo_sticking_details.png?nolink&200x193}} _ CODE {{:fabricademy2017:students:pauline_bianchi:electronics_ii:capture_d_ecran_2017-11-30_a_14.46.06.png?nolink&500x563}} The sensor was capting different intensity of light and was producing sound from the piezo : {{:fabricademy2017:students:pauline_bianchi:electronics_ii:capture_d_ecran_2017-11-30_a_15.03.00.png?nolink&1000x578}} I tried with a Piezo buzzer instead. The sound is louder and has a different tonality depending on the code. you can find the link [[https://youtu.be/iWZ6pqbe-ZQ|HERE]]. {{:fabricademy2017:students:pauline_bianchi:electronics_ii:img_5040.jpg?nolink&500x374|img_5040.jpg}} I tried with another code from the tutorial of [[https://youtu.be/WLLiiyWKxs8|Massimo Banzi]] and the sound has a different tonality. cf [[https://youtu.be/Db80nwXNTiE|HERE]]. ___ to be able to integrate this circuit into a fabric, I was thinking to use a ATtiny85 but unfortunately the Arduino "Tone" function is not supported on the ATtiny85 because it doesn't have the appropriate timers. I therefore needed to find a replacement way of generating simple tones. [[https://drive.google.com/open?id=1oiuKLGcyv26BYSCxaXGjiJSuigdh3D4G|Links]] ---- Code : //LED pin \\ const int ledPin= 13; \\ int sensorValue; \\ int sensorHigh; \\ int sensorLow; void setup() { \\ // put your setup code here, to run once: \\ pinMode(ledPin, OUTPUT); \\ digitalWrite(ledPin, HIGH); // calibrate during the first five seconds \\ while (millis() < 5000) { \\ sensorValue = analogRead(A0); // record the maximum sensor value \\ if (sensorValue > sensorHigh) { \\ sensorHigh = sensorValue; \\ } // record the minilum sensor value \\ if (sensorValue < sensorLow) { \\ sensorLow = sensorValue; \\ } \\ \\ } // signal the end of the calibration period \\ digitalWrite(ledPin, LOW); } void loop() { \\ // read the input from A0 \\ sensorValue = analogRead(A0); // map the sensor values to a wide range of pitches \\ // adjust the values bellow to conform the maximum and minimum \\ // numbers you get from your sensor \\ int pitch =map(sensorValue, sensorLow,sensorHigh, 50, 4000); // play the tone \\ tone(8,pitch,20); // wait for a moment \\ delay(10); }