[p-com] Final project progress report

Did we make some progress? Yes we did. How much is left to do? No idea.

First of all here’s a 3d model for reference

Interaction

We decided to use flash light as interaction device; you’d have to point the light directly into each room to trigger new video sequence.

const int photocellPin = A0; 
const int ledPin = 9;
int ledBrightness;
int photocellReading;
const int pcThreshold = 900;

int value;

void setup(){
 pinMode(ledPin, OUTPUT); 
 pinMode(photocellPin, INPUT);
}

void loop(){
  photocellReading = analogRead(photocellPin);
  Serial.print("photocellReading: ");
  Serial.println(photocellReading);
  ledBrightness = map (photocellReading, 0, 1023, 0, 255);
  if (photocellReading > pcThreshold) {
    analogWrite(ledPin, ledBrightness);
    Serial.println(ledBrightness);
  } else {
    analogWrite(ledPin, 0); 
  } 
  delay(10);
}

Thinking about signal communication, we thought about using Serial in TouchDesigner, and then using MadMapper for projection mapping. Later we found out that MadMapper has MIDI integration, so it seems much easier if we can directly send out MIDI signal from Arduino. Thanks to Mai Clear, who is continuously being my savior and suggested the MIDIUSB library for Arduino NANO. I don’t fully understand MIDI signals yet, but I used part of the example on GitHub.

void noteOn(byte channel, byte pitch, byte velocity) {
  midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, velocity};
  MidiUSB.sendMIDI(noteOn);
}

void noteOff(byte channel, byte pitch, byte velocity) {
  midiEventPacket_t noteOff = {0x08, 0x80 | channel, pitch, velocity};
  MidiUSB.sendMIDI(noteOff);
}

void controlChange(byte channel, byte pitch, byte velocity) {
  midiEventPacket_t event = {0x0B, 0xB0 | channel, pitch, velocity};
  MidiUSB.sendMIDI(event);
}

…and implemented it so that two push buttons and a photocell each produce a different note (in garage band):

void loop() {
  button1Reading = digitalRead(button1Pin);
  button2Reading = digitalRead(button2Pin);
  photocellReading = analogRead(photocellPin);

  //led
  ledBrightness = map (photocellReading, 0, 1023, 0, 255);
  if (photocellReading > pcThreshold) {
    digitalWrite(ledPin, HIGH); 
    noteOn(0, note3, 64); //channel, pitch, velocity 
    delay(3000);
    Serial.println(ledBrightness);
  } else {
    digitalWrite(ledPin, LOW); 
  } 
  delay(10);

  //midi
  if (button1Reading == HIGH) {
  noteOn(0, note1, 64); //channel, pitch, velocity 
  delay(300); 
  }
  if (button2Reading == HIGH) {
  noteOn(0, note2, 64); //channel, pitch, velocity 
  delay(300);
  }
}

Now we can switch scenes in MadMapper with a simple button click :`)

Fabrication

Leave a Reply

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