Trat – bluetooth and sound

After almost everything got erased, I fortunately, found a backup of the animation I have saved and had to recreate all the other things such as the videos the Max patch and the Arduino code. That experience thought me a big lesson to always backup my stuff, but also that it take less time to do something on the second time.

Here is the result:

 

One of the main improvements from last week was to wirelessly connect between the laser break-beam that lives in the trash can and the Max patch that is on the computer. At first, I tried to use RedBear but I could not connect it to the Arduino. Then I switched to a BlueFruit to send the outputs to the computer- if the laser broke or not and from there to the max patch.

I used Adafruit’s guidelines to hook up the BlueFruit:

adafruit_products_1588arduino_LRG

Adafruit’s Bluefruit wiring

 

IMG_5383

My wiring (Bluefruit and laser break-beam)

I did not add anything special to the Arduino code, but I did do the following steps:

  1. Pair the computer to the EZ-Link
  2. Change the Arduino port to “/dev/cu.AdafruitEZ-Link4c98-SPP
  3. Upload the Arduino code (after uploading the code through Bluefruit I could not open the Serial Monitor of the Arduino).
  4. close Arduino and open Max

Note: when the Arduino code is being uploaded both Red light and Blue light on the Bluefruit should flicker!!

Arduino code:

int laser = 2;
int led = 3;

int button = 0;
int count = 0;

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

pinMode(laser, INPUT_PULLUP);
pinMode(led, OUTPUT);
Serial.println(button);
}

void loop() {
int val = digitalRead(laser);
if (val == 1 && button == 0) {
digitalWrite(led, HIGH);

button = 1;
count = -1;

Serial.println(button);

}
else if (val == 0 && count >= 1000 && button == 1) {

digitalWrite(led, LOW);

button = 0;
count = 0;
Serial.println(button);
}

count++;
delay(5);

// Serial.println(count);

}

 

My biggest difficulty was the Max patch. The way it is as for now, I need to restart it every time since it doesn’t return to the first video.

[Add a print screen of the max patch]!!!

Categories: Readymades

Leave a Reply

Your email address will not be published. Required fields are marked *