arduino data


    Jan 05 2013 | 2:54 pm
    hello friends,
    i am new to arduino and max.
    i have a connection from arduino to max and i would like to read the digital pin (number 8 and 9)!
    it works fine in max but i want this:
    I have a Capacitive Sensor attached to arduino and want to show/read
    the differences in my value (works in arduino serial monitor) but in max i only get two consistent values.
    can anyone help me?
    this is my max patch:
    cheers flo

    • Jan 05 2013 | 7:44 pm
      Hi
      without seeing your Arduino code this is a little vague, so I suggest removing the [atoi] object in your Max patch and checking to ensure that the code is outputting the correct format (8-bit ASCII). If you're getting readings in the serial monitor window in Arduino then that's good; look in your code for the "sending" function:
      Serial.print(xxx, BYTE);
      or
      Serial.write(xxx);//newer Arduino boards and IDE
      and make sure there's no Serial.println.
      but we'd really need to see the Arduino code
      Brendan
      ps
      study materials here:
    • Jan 06 2013 | 4:28 am
      Agreed with Brendan, we'd need your matching Arduino code to be able to debug the issue.
    • Jan 10 2013 | 4:21 pm
      thanks for your fast reply!
      brendan ive tried it without the Serial.println but its the same.
      the value stays the same if i touch the Capacitive Sensor or not!
      ardunio code is from paul badger:
      here it is:
      int i;
      unsigned int x, y;
      float accum, fout, fval = .07; // these are variables for a simple low-pass (smoothing) filter - fval of 1 = no filter - .001 = max filter
      int ledPin = 5; // select the pin for the LED
      float nonTouched, store = 0;
      void setup() {
      Serial.begin(9600);
      //DDRB=B101; // DDR is the pin direction register - governs inputs and outputs- 1's are outputs
      // Arduino pin 8 output, pin 9 input, pin 10 output for "guard pin"
      // preceding line is equivalent to three lines below
      pinMode(8, OUTPUT); // output pin
      pinMode(9, INPUT); // input pin
      pinMode(10, OUTPUT); // guard pin
      digitalWrite(10, LOW); //could also be HIGH - don't use this pin for changing output though
      pinMode(5, OUTPUT);
      analogWrite(ledPin,255);
      delay(10);
      analogWrite(ledPin,0);
      }
      void loop() {
      y = 0; // clear out variables
      x = 0;
      for (i=0; i < 4 ; i++ ){ // do it four times to build up an average - not really neccessary but takes out some jitter
      // LOW-to-HIGH transition
      //PORTB = PORTB | 1; // Same as line below - shows programmer chops but doesn't really buy any more speed
      digitalWrite(8, HIGH);
      // output pin is PortB0 (Arduino 8), sensor pin is PortB1 (Arduinio 9)
      //while ((PINB & B10) != B10 ) { // while the sense pin is not high
      while (digitalRead(9) != 1) { // same as above port manipulation above - only 20 times slower!
      x++;
      }
      delay(1);
      // HIGH-to-LOW transition
      // PORTB = PORTB & 0xFE; // Same as line below - these shows programmer chops but doesn't really buy any more speed
      digitalWrite(8, LOW);
      //while((PINB & B10) != 0 ){ // while pin is not low -- same as below only 20 times faster
      while(digitalRead(9) != 0 ) { // same as above port manipulation - only 20 times slower!
      y++;
      }
      delay(1);
      }
      fout = (fval * (float)x) + ((1-fval) * accum); // Easy smoothing filter "fval" determines amount of new data in fout
      accum = fout;
      store++;
      if (store nonTouched = fout;
      }
      if (store>50){
      store = 50;
      }
      Serial.print((long)x, DEC); // raw data - Low to High
      Serial.print( " ");
      Serial.print((long)y, DEC); // raw data - High to Low
      Serial.print( " ");
      Serial.print( (long)fout, DEC); // Smoothed Low to High
      Serial.print( " ");
      if (fout>nonTouched+3){
      analogWrite(ledPin,255);
      }
      else{
      analogWrite(ledPin,0);
      }
      }
    • Jan 10 2013 | 7:10 pm
      Hi
      Are you still getting a variable reading in the Arduino monitor window? If so, please post a small screenshot of the readings. My Arduino chops aren't great but it appears that this code is only generating an "on/off" transition. It's also likely I'm wrong
      B
    • May 01 2013 | 2:45 pm
      sorry for not answering in a while! hadnt time for this project!
      i have this readings from arduino
      screen 1 - non touched
      screen 2 - touched
      it works fine but now i want to read this different values in max so i can start playing a video when i touch my object...thats my goal...
      [attachment=222541,5523] [attachment=222541,5524]
    • May 01 2013 | 7:33 pm
      Hi
      here are two resources to help you on your way:
      What I tend to do is use Serial.write(myValue) or Serial.print(myValue, BYTE), terminated with a Serial.println(). Delete any lines in your Arduino code that aren't printing the actual sensor data. This will send a stream of 8-bit value(s) with no need to convert to/from ascii. It's also quite simple to send the data in its full 10-bit resolution, but I've yet to find the need for it.
      Then in Max use either [zl group] or [match] as Steven Miller does in his excellent didactic patch in the above thread. Also, search this forum using the keywords "arduino" "parsing multiple sensors" etc.
      Keep us posted
      Brendan
    • May 03 2013 | 12:36 pm
      thanks for your help guys...
      i am a lot further now in the project...
      now i get a good value from my arduino...if i touch my object the value gets 40 then i send a bang and want to record a movie with my webcam...
      my goal is now to record a 60sec movie from my webcam and store it in a folder "xy" and play a random video from the same folder "xy" at the same time.
      do you think thats possible...thanks....
      thats my max project right now:
    • May 13 2013 | 8:43 am
      hello max friends...
      the record time works fine...i set a bang delay to trigger the stop function of the record....
      now i have another problem...i want to save the records in one folder and dont overwrite it!
      i want to save it as
      xx1
      xx2
      xx3
      xx4
      xx5
      can you help me?!!
      thanks for your help...really appreciate it.
      greetz from austria