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!
The delay
object simply delays any messages it receives.
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”).
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.
The metro
object is a type of metronome, an object that constantly sends a “bang” at a regular time-interval.
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.
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.
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”.
The random
object generates a random number within the range between 0 and the number you write in.
random
object in the patch at step 7 instead of counter
.The change object is crucial for working with the Arduino Module. We will explain it here with an example in two steps:
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.
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.
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.