Week 3 – Max Objects / Disco Lights

Opdracht 1 : Build this Arduino circuit

Build the following Arduino set up and use the Arduino code given to you in the Max/Arduino module.

In Max/MSP use the MaxArduino module and make a code that does the following:
When you press the switch on the Arduino, all LEDs turn on, when you release, all LEDs turn off.

Once you are done, put it asside and lets learn a few new objects!

Max/MSP : “Delay” object

The delay object simply delays any messages it receives.

  1. Please build the following in Max:

    You will notice that when you click on the top bang, the output bang comes 1000 milliseconds (1 second) later. Delays are useful when you need a simple sequence that responds to a users input.

Max/MSP : “Counter” object

The counter is an object that counts “bangs”, it is very useful because it can count in many different ways depending on the arguments you give the object (arguments are seen to the left of the word “counter”).

  1. In the same Max window please build the following:

    You will notice that when you click on the top “bang” the counter outputs the number of times it has received a hit. In this default setting it will simply count up forever.

  2. Please edit the previous counter object:

    You will notice that now the count goes to 12 and then starts over. This can create a loop counter if you want to build a sequence and trigger something different depending on which step of the counter you are.

Max/MSP : “Metro” object

The metro object is a type of metronome, an object that constantly sends a “bang” at a regular time-interval.

  1. In the same Max window please build the following:

    When you turn on the “toggle” object above metro you will see a regular bang being triggered. The time it takes between bangs is set to 500 milliseconds (half second). Try changing the 500 to 1000 and see what happens (then try setting it to 250).

  2. Add the following to the metro example

    Now attach a counter to the end of the metro/bang example in step 4 and we now have a sequencer that counts up to 4 every 2 seconds. We can then customize the response of the metro based on a sequence that counts up to 4.

  3. Add the following to the metro example

    We will now use the sel (select) object to do something different depending on where in the sequence the metro-controlled counter is. In this example you will see how each bang object turns on in sequence.

  4. Add the following to the metro example

    Now we are changing the “bangs” to “toggles”. If we just add the toggles then the sequence will turn them on, but not turn them off until the sequence repeats. We use the “delay” object to turn off the toggle after 500 milliseconds. When we turn on the metro object you will see the sequence flipping the toggle and then turning it off.
    NOTE: make sure you complete the step by adding the 2 missing “delays”.

Max/MSP : “Random” object

The random object generates a random number within the range between 0 and the number you write in.

  1. Replace counter to random object in order to randomize the output number.

    Beware that the random object gives output from 0. In order to generate the number between 1 and 4, we need to add 1 to the output. That is why there is ‘+ 1’ is added below random.
    Now try to use random object in the patch at step 7 instead of counter.

Max/MSP : “Change” object

The change object is crucial for working with the Arduino Module. We will explain it here with an example in two steps:

  1. Please build the following

    When you press your Arduino switch and release it look at the post window. It should be “raining bangs” in the console.

  2. now add the change object

    Now when you press the switch on your Arduino and release it you should only see a “1” once and a “0” once everytime you click it.
    So that when you add the “change” to your “metro” example it should now function as expected.

Opdracht 2-1 : Disco Lights

Use the Arduino setup you made in Opdracht 1.

Use the “metro” example you just made. Make the Arduino switch turn on/off the toggle on the metro.

Next, connect the 4 “toggles” on the bottom of the Max patch to each of the 4 LEDs. If this is done correctlly your LEDs will light up in sequence like the toggles on your max patch.

Opdracht 2-2 : Random Disco Lights

Use the Arduino setup and the max patch you made in Opdracht 2-1.
Instead of making the LEDs turning on in sequence from 1 to 4, make a random light to turn on each time.