basic Arduino connections to Max

  • Dim an LED from Max.
  • Read the value of a potentiometer in Max.

download

https://github.com/tkzic/max-projects

folder: arduino-basics

patches:

  • arduino-dimmer.maxpat
  • arduino-serial-read.maxpat

Arduino dimmer

dim an LED from Max

From the Arduino playground

http://playground.arduino.cc//Code/MaxCommunicationExamples

circuit

Connect an LED to pin 9 and ground. The shorter lead goes to ground.

sketch

Load the Arduino example sketch: communications | dimmer

Max
  1. open arduino-dimmer.maxat
  2. Click the “print” message to print the list of ports to the Max window. Then set the port in the serial object, using the port message. For example: “port c”.
  3. Move the slider to dim the LED

Arduino serial read

Read the value of a potentiometer

This patch is a bit more involved. Refer to the Max Communications Tutorial 2: Serial Communication. In fact, much of this code was lifted from the tutorial.

circuit
  • Connect an LED to pin 9 and ground. The shorter lead goes to ground.
  • Connect a potentiometer (center lead) to Analog pin 0. The sideĀ leads connect to +5v and ground.
sketch

Load the Arduino example sketch: Analog | analogInOutSerial

Max
  1. Open arduino-serial-read.maxpat
  2. Click the “print” message to print the list of ports to the Max window. Then set the port in the serial object, using the port message. For example: “port c”.
  3. Activate toggle to start polling serial port
  4. Activate toggle number 3 to view formatted output in the Max window
  5. Turn the potentiometer to send data to Max

general suggestions:

  • Try not to get discouraged.
  • If weird things happen, close Max, reconnect Arduino, the re-open Max