NIME: Instrument 2

Title: Delayed

(sorry for not being able to rotate the video)

Description: The instrument is done with Arduino and Processing and it uses 2 LDR sensor to synthesis the frequency of a sound wave formed through the Processing library called Minim. Each sensor is surrounded by a cylinder made out of black paper. One of the sensors sends values to Processing which affect the amplitude of the sound wave, and the other one adjusts the frequency at which 2 LED lights blink. Each sensor is surrounded by a cylinder made out of black paper. Furthermore, the two LED lights are placed inside the same cylinder with the sensor that modifies the amplitude.

In short, one of the sensors affects the rate at which the LED lights blink, which affect the values that the other sensor send to Processing in order to adjust the amplitude of the sound wave.

Materials: Arduino, Processing, 2 LDR sensors, 2 LED lights, jumper cables, 2 10K resistor, 2 220R resistors, black paper, tape, flashlight.

Process:

First, I connect power and ground from Arduino to the breadboard. Then I placed two LDR sensors on the breadboard and connected one of their pins to power and the other one to a 10K resistor which was also connected to an analog input pin. Next, I placed two LED lights on the breadboard and connected one of their pins to ground and the other one to a 220R resistor which was connected to a digital input pin. This can be seen in the pictures below:

Afterwards, I decided to user black paper and fold it into a cylinder so that the LDR sensors would receive more accurate light values. Moreover, since the two LED lights are used to trigger one of the LDR sensors, I thought it would be more convenient to use the black paper as is can be seen below:

 

For the Arduino code, I created int variables for the number of the analog pins, the digital pins, for the values received by the LDR sensors, for the state of the LED lights, for the interval between each LED state, and for the milliseconds used to determine the interval. In the setup function I started the serial communication with 9600, created two pin modes for the LED lights, and declared the interval to be 500 milliseconds. In the loop function, I declared the two LDR int values to read the analog values from the sensors, and then set the interval variable to be equal to the value received from the sensor without the LED lights. Then I created another variable called currentMillis which is equal to the function that counts the milliseconds. After, I made an if statement so that if the value of currentMillis mines previousMillis is greater or equal to the interval, then previousMillis equals currentMillis. Inside this if statement I created another one where if the led state is low, the it becomes high and vice versa. Lastly, I sent the values of the sensors from Arduino to Processing.

In the Processing code, I first had to add the Minim and the serial library, and created an object for the serial, for the minim, for an audio output of minim, and for a sound wave of the Oscil object in the minim library. I also created float values for the frequency of the Oscil object, and integer for the number of sensors, and an array and a string for the values of the sensors. In the setup function I declared my serial object to equal my Arduino port, set the values array to equal the number of sensors, declared the Oscil object to have a frequency of 440 Hz and to be a sine wave, and patched the audio output object to the Oscil object. In the draw function I created a while loop in order to read the values from Arduino. Inside this loop I had to split the data of the values and trim them in order to be able to read the actual number values. Next,  I set the variable for the frequency values to be the mapping function of the sensor value and set it between 110 and 880.  And lastly, I used one of the given function of the minim library to make the frequency  values be the same as that of the sound wave.

Difficulties:

Throughout the development of my project, I noticed that Processing was taking a long time to receive the information from my Arduino, but I could not figure out why. So in order to have a wider variety of sounds, I decided to implement the LED blinking. However, Antonius looked at my code and saw that I had created an if statement in order to read the Arduino values instead of a while. Thus, one of the most important things I have learned is that I really sound not use an if statement when trying to read Arduino values.

Leave a Reply