maxuino and max 6 ...


    Apr 16 2012 | 9:41 pm
    Hi,
    Maxuino works perfectly fine with max 5, but what about max 6?
    Does anyone have good/bad experiences with maxuino and max 6?
    Are there other ways of connecting an arduino uno to max and get ALL analogue inputs into max while still being able to control LED lights via the PWM outputs? (The code seems pretty complicated to do from scratch from both the max and the arduino side ...)
    Thanks for your help,
    Kaspar

    • Apr 16 2012 | 9:56 pm
      Hmm ... I downloaded max 6, and maxuino doesn't seem to work in max 6.
      Is there an easy way in max 6 to both get analogue input data from the arduino _and_ at the same time control LEDs with the PWM output from max?
      Thanks for your help!
      Kaspar
    • Apr 16 2012 | 10:03 pm
      Hi Kaspar,
      I have max6 and have got Maxuino to work ok with it. There is a PWM function included in it but it doesnt seem to create the "fade" effect on the LED's that you would get doing it using arduino code. Im trying to do something similar in my project which I have just asked about in the forum.
    • Apr 16 2012 | 10:04 pm
      SensorBox works in max 6.
      Is here a way that I can add some code to the SensorBox.pde file, so that the arduino can receive messages from max to control the pwm pins on the arduino uno?
      K
    • Apr 16 2012 | 10:57 pm
      If you're just looking to fade LEDs, why not start from this example sketch and use the included Max patch? http://www.arduino.cc/en/Tutorial/Dimmer
    • Apr 17 2012 | 8:14 am
      Thanks for the suggestion with the Dimmer tutorial. Then at least the LED control problem is solved.
      However, the arduino sensorBox code combined with the arduino dimmer tutorial code is still a problem, because data needs to be sent back and forth at the same time. I wonder if anyone has solved this problem? I am working on it right now, but it is quite complicated to do for a beginner in arduino code ... any hints/good advice?
      K
    • Apr 17 2012 | 1:33 pm
      There are other Communication examples that explain how to send data both ways. http://arduino.cc/en/Tutorial/SerialCallResponseASCII and http://arduino.cc/en/Tutorial/SerialCallResponse show how you can send multiple bytes from the Arduino, and have it receive something from Max.
    • Apr 18 2012 | 7:02 pm
      Hi Scott and thanks for the advice,
      Now I am trying to combine the serialCallResponse example with the dimmer example, and I almost have something working (see below posted codes). However, it looks like the LED is getting updated to full strength everytime I send a new slider value to the LED from max ... what do I do wrong in the arduino/max code?
      Arduino code:
      int firstSensor = 0; // first analog sensor int secondSensor = 0; // second analog sensor int thirdSensor = 0; // digital sensor int inByte = 0; // incoming serial byte const int ledPin = 9; // the pin that the LED is attached to
      void setup() { // start serial port at 9600 bps: Serial.begin(9600); // initialize the ledPin as an output: pinMode(ledPin, OUTPUT); pinMode(2, INPUT); // digital sensor is on digital pin 2 establishContact(); // send a byte to establish contact until receiver responds }
      void loop() { byte brightness; // if we get a valid byte, read analog ins: if (Serial.available() > 0) { // read the most recent byte (which will be from 0 to 255): brightness = Serial.read(); // set the brightness of the LED: analogWrite(ledPin, brightness); // get incoming byte: //inByte = Serial.read(); // read first analog input, divide by 4 to make the range 0-255: firstSensor = analogRead(A0)/4; // delay 10ms to let the ADC recover: delay(10); // read second analog input, divide by 4 to make the range 0-255: secondSensor = analogRead(1)/4; // read switch, map it to 0 or 255L thirdSensor = map(digitalRead(2), 0, 1, 0, 255); // send sensor values: Serial.write(firstSensor); Serial.write(secondSensor); Serial.write(thirdSensor);
      } }
      void establishContact() { while (Serial.available() Serial.print('A'); // send a capital A delay(300); } }
      max code:
    • Apr 18 2012 | 7:18 pm
      OK, a tiny change in the code makes it work a bit better, but the LED light is still a bit flaky when the value is changed.
      arduino code:
      int firstSensor = 0; // first analog sensor int secondSensor = 0; // second analog sensor int thirdSensor = 0; // digital sensor int inByte = 0; // incoming serial byte const int ledPin = 9; // the pin that the LED is attached to
      void setup() { // start serial port at 9600 bps: Serial.begin(9600); // initialize the ledPin as an output: pinMode(ledPin, OUTPUT); pinMode(2, INPUT); // digital sensor is on digital pin 2 establishContact(); // send a byte to establish contact until receiver responds }
      void loop() { byte brightness; // if we get a valid byte, read analog ins: if (Serial.available() > 0) { // get incoming byte: inByte = Serial.read(); // read the most recent byte (which will be from 0 to 255): brightness = Serial.read(); // set the brightness of the LED: analogWrite(ledPin, brightness); // read first analog input, divide by 4 to make the range 0-255: firstSensor = analogRead(A0)/4; // delay 10ms to let the ADC recover: delay(10); // read second analog input, divide by 4 to make the range 0-255: secondSensor = analogRead(1)/4; // read switch, map it to 0 or 255L thirdSensor = map(digitalRead(2), 0, 1, 0, 255); // send sensor values: Serial.write(firstSensor); Serial.write(secondSensor); Serial.write(thirdSensor);
      } }
      void establishContact() { while (Serial.available() Serial.print('A'); // send a capital A delay(300); } }
      max code:
      ... I am not sure if this is the right way to do it, but at least close to working.
      K
    • Apr 18 2012 | 8:09 pm
      You had it better with the first Arduino sketch.
      Originally you were sending a 65 in addition to the value you wanted. Not sure what you were trying with that second sketch.
      int firstSensor = 0; // first analog sensor int secondSensor = 0; // second analog sensor int thirdSensor = 0; // digital sensor int inByte = 0; // incoming serial byte const int ledPin = 9; // the pin that the LED is attached to
      void setup() { // start serial port at 9600 bps: Serial.begin(9600); // initialize the ledPin as an output: pinMode(ledPin, OUTPUT); pinMode(2, INPUT); // digital sensor is on digital pin 2 establishContact(); // send a byte to establish contact until receiver responds }
      void loop() { byte brightness; // if we get a valid byte, read sensors //and use that byte to change the LEDs brightness: if (Serial.available() > 0) { // read the most recent byte (which will be from 0 to 255): brightness = Serial.read(); // set the brightness of the LED: analogWrite(ledPin, brightness); // read first analog input, divide by 4 to make the range 0-255: firstSensor = analogRead(A0)/4; // delay 10ms to let the ADC recover: delay(10); // read second analog input, divide by 4 to make the range 0-255: secondSensor = analogRead(1)/4; // read switch, map it to 0 or 255L thirdSensor = map(digitalRead(2), 0, 1, 0, 255); // send sensor values: Serial.write(firstSensor); Serial.write(secondSensor); Serial.write(thirdSensor);
      } }
      void establishContact() { while (Serial.available() Serial.print('A'); // send a capital A delay(300); } }
      `
    • Apr 18 2012 | 10:26 pm
      Ahh, Thanks :-)
      Kaspar