Close

Week 13

A project log for Dynamic Interactive - Urbanscapes

This is a school project that follows Urbanscapes Malaysia brief, to create an interactive design related to Malaysia art and culture.

aprilmomo0416aprilmomo0416 12/20/2018 at 04:460 Comments

12th December, 2018-Wednesday

Rushing for Submission

So 13th Dec its the submission day, we really very worry about couldn't finish on time. And also we did apply to stay overnight tonight, but it comes out decline the approver from the department, so we don't have much time . But we will try our very best, and it because of Wednesday Fab Lab is having classes, and everyone is waiting for 3Dprint and  Laser cut, so come out we have to wait everybody to finish their stuff then we only can use it.

For the coding part, we only have around 1 week to explore on processing, and we still could not get any audio play by trigger. I could not really get help from my classmates because I'm the only one who are using processing and no one else know how to use it, so we get help from our senior, but at the end it is still not working. We have trouble on checking the code during the whole process because of the unstable connection of Arduino port, but at the end we still could not read signal from Arduino on Processing.

import processing.sound.*;

import processing.serial.*;

int button1;
int button2;
int button3;
int button4;
int buttonLock1 = 0;
Serial myPort;
int[] serialInArray = new int[4];
int serialCount = 0;
boolean firstContact = false;

String val;

SoundFile BGSound;

SoundFile Convo1;
SoundFile Convo2;
SoundFile Convo3;
SoundFile Convo4;

void setup()
{
  printArray(Serial.list());
  String portName = Serial.list()[2];
  myPort = new Serial(this, portName, 9600);

  BGSound = new SoundFile(this, "BG.mp3"); 
  Convo1 = new SoundFile(this, "2.mp3"); 
  Convo2 = new SoundFile(this, "3.mp3"); 
  Convo3 = new SoundFile(this, "4.mp3"); 
  Convo4 = new SoundFile(this, "5.mp3"); 

  //BGSound.loop();
  //Convo2.play();
}

void draw()
{
  //if ( myPort.available() > 0) {  // If data is available,
  //  //val = myPort.readString();         // read it and store it in val

  //  val = myPort.readString(); 
  //  //println(val);
  //}

  //if (val == "f") {
  //  println("play");
  //   Convo1.play();
  //   Convo2.stop();
  //   Convo3.stop();
  //   Convo4.stop();
  //}  
  //if (val == "h") {
  //   Convo1.stop();
  //   Convo2.play();
  //   Convo3.stop();
  //   Convo4.stop();     
  //}  
  //if (val == "H1") {
  //   Convo1.stop();
  //   Convo2.stop();
  //   Convo3.play();
  //   Convo4.stop();
  //}  
  //if (val == "H2") {
  //   Convo1.stop();
  //   Convo2.stop();
  //   Convo3.stop();
  //   Convo4.play();
  //}
}

void serialEvent(Serial myPort) {
  // read a byte from the serial port:
  int inByte = myPort.read();
  // if this is the first byte received, and it's an A,
  // clear the serial buffer and note that you've
  // had first contact from the microcontroller. 
  // Otherwise, add the incoming byte to the array:
  if (firstContact == false) {
    if (inByte == 'A') { 
      myPort.clear();          // clear the serial port buffer
      firstContact = true;     // you've had first contact from the microcontroller
      myPort.write('A');       // ask for more
    }
  } else {
    // Add the latest byte from the serial port to array:
    serialInArray[serialCount] = inByte;
    serialCount++;

    // If we have 3 bytes:
    if (serialCount > 3 ) {
      //xpos = serialInArray[0];
      //ypos = serialInArray[1];
      button1 = serialInArray[0];
      button2 = serialInArray[1];
      button3 = serialInArray[2];
      button4 = serialInArray[3];
      //println(button1);

    if (buttonLock1 == 0){
      if (button1 == 1) {
        println("play");
        Convo1.play();
        Convo2.stop();
        Convo3.stop();
        Convo4.stop();
        buttonLock1 = 1;
      }
    }
    if (button1 == 0){
      buttonLock1 = 0;
    }
    
    if (buttonLock1 == 0){
      if (button1 == 1) {
        println("play");
        Convo1.play();
        Convo2.stop();
        Convo3.stop();
        Convo4.stop();
        buttonLock1 = 1;
      }
    }
    if (button1 == 0){
      buttonLock1 = 0;
    }
    
    if (buttonLock1 == 0){
      if (button1 == 1) {
        println("play");
        Convo1.play();
        Convo2.stop();
        Convo3.stop();
        Convo4.stop();
        buttonLock1 = 1;
      }
    }
    if (button1 == 0){
      buttonLock1 = 0;
    }
    
    if (buttonLock1 == 0){
      if (button1 == 1) {
        println("play");
        Convo1.play();
        Convo2.stop();
        Convo3.stop();
        Convo4.stop();
        buttonLock1 = 1;
      }
    }
    if (button1 == 0){
      buttonLock1 = 0;
    }
    
    if (buttonLock4 == 0){
      if (button4 == 1) {
        println("play");
        Convo1.play();
        Convo2.stop();
        Convo3.stop();
        Convo4.stop();
        buttonLock4 = 1;
      }
    }
    if (button4 == 0){
      buttonLock4 = 0;
    }
      
      // Send a capital A to request new sensor readings:
      myPort.write('A');
      // Reset serialCount:
      serialCount = 0;
    }
  }
}

13th December, 2018-Thursday

Submission

The time submission is 4.00pm. But we still left more parts haven't done. 

The prior of today is to settle the code and wire everything up.

Before 4pm, we asked our lecturer about how to read signal from Arduino in processing, turns out, we don't need to use serial communication since our project are just using processing to output the sound, we change the code to Serial read, which is very simple and not confusing, and for the first we receive the signal from Arduino in Processing!

Submission extended one more week because at 4pm, most of us have not done our projects.

Discussions