PCOM – Week 04

Project 1

For this project 1, I made to create a simple audio visual interface. The idea is that with 2 Iron balls which are input, and it makes two different notes sound at different times, depending on the position of the balls, so that the user can compose with them. So, I wanted to make a composition of sound through simple interaction.

The principle is simple. Each of the eight holes has in a photo-transistor, which makes a sound when it is blocked on the hole.

Arduino can make only one sound at a time even if I pressed two notes at the same time as below.

Therefore, I gave a delay each tone in the code to make the two different sounds at different times. With two speakers, Do and mi are used the same speaker1 and Re and Pa used the same speaker2. I used the photo register(cds) here for a test. The sound worked well with as intended.

After I made code for 8 notes, I prepared to make a box. I cut out the beech tree piece with laser cut machine and prepared materials for the box as below.

  • beech 800x400mm
  • laser cut machine
  • bond for wood
  • Iron Ball 2 (30mm)
  • speaker 4 ohm3w/ 8 ohm10w
  • photo transistor
  • aligator clips
  • jumper wires

It took longer than I thought for bonding pieces of wood box. one piece at a time and then glue it to dry. So, It took more than 2 hours as I had to work on it one by one.

After completing the box, I connected my arduino, photo transistors, and jumper wires.


The following are the results. It works as well as I intended.

Final output

Code

void setup()
{ Serial.begin(9600);
}

void loop()
{
  int read1 = analogRead(A0);
  int read2 = analogRead(A1);
  int read3 = analogRead(A2);
  int read4 = analogRead(A3);
  int read5 = analogRead(A4);
  int read6 = analogRead(A5);
  int read7 = analogRead(A6);
  int read8 = analogRead(A7);
  if (read1 < 1) {
    noTone(8);
    // play a note on pin 8 for 200 ms:
    tone(11, 262,200);
    delay(1000);
  }
  else noTone(11);

  if (read2 < 1) {
    tone(8, 294,200);
    delay(1000);
  }
  else noTone(8);

  if (read3 < 1) {
    tone(11, 330,200);
    delay(1000);
  }
  else noTone(11);

  if (read4 < 1) {
    tone(8, 349,200);
    delay(1000);
  }
  else noTone(8);

  if (read5 < 1) {
    tone(11, 392,200);
    delay(1000);
  }
  else noTone(11);

  if (read6 < 1) {
    tone(8, 440,200);
    delay(1000);
  }
  else noTone(8);

  if (read7 < 20) {
    tone(11, 494);
    delay(500);
  }
  else noTone(11);

  if (read8 < 20) {
    tone(8, 523);
    delay(800);
  }
  else noTone(8);

}

I learned that if the amount of light varies from time to time, the sensor’s value changes accordingly, so that sometimes the sound is heard and sometimes it doesn’t.
For this, I had to change the sensor’s values continuously.
So I mainly worked under fluorescent lights, which receive a constant amount of light (at night!).

Also, the speaker sound is smaller than I thought, so I wonder if I need an amplifier to raise the speaker sound.

I think the sound is sooo digital. So, if I make a tinkling sound like keyboard by a mp3 module, I think my work will be better.