Read analog input from arduino

    Aug 06 2009 | 7:23 pm
    I'm building a sample trigger whit arduino based on a piezo input, all max patch is set except, when i read the analog values from arduino, as i see the values came without stopping, and i have a very hard time trying to extract only the maximum value and stop the values flow, and when the sample is played i must have all back to get the new maximum value. Here is what i got so far.
    thanks for any help.
    Luis Marques

    • Aug 07 2009 | 12:27 am
      Try a combo w. [clip] so you can have the values trapped between a max and min values. Then use [scale] to change how the values are output.
      Or as you phrased it, you can use [peak] the have the max N
      Sorry I am not on a computer that has MAXMSP installed, so I can't do a patch for you.
      Again, maybe what is not necessarily to stop the values flow
      have a look @ N matching objects like:
      [Select] [route] [match]
      You might gate w. Value (very practical) [int] [float]
      Maybe even
      good luck
    • Aug 07 2009 | 6:07 am
      thanks for the answer.
      I really need to stop that flow... When you hit the piezo he give a value between 0. and 100. (for example), if i let trough values between 70 and 100 whit split object, it will constant outputting values from 70 to 100 and back, from 100 to 70, so i got not one bang, but 60 bangs (if all values are captured), i really need something that stops the flow to get only one output bang and extract the peak of that impact.
      Luis Marques
    • Aug 07 2009 | 7:42 am
      here is a patch that is a complete hack but works fine to do what I think you wanted (only output once if between 70-100, anything under 70 will reset it)
    • Aug 07 2009 | 8:08 am
      yes, it's working. but it's not precise between 2 impulses. For making that i think it needs something to update the this is needed because if it hit the piezo once it gives me the value of 80, and then the sound is triggered, but after i hit again and the value that is checked have no time to get under the 70, so it miss one shot...
      Luis Marques
      Is is possible to extract only the first bang of 30 from the arduino?
    • Aug 07 2009 | 3:02 pm
      maybe this is what you mean. Sorry if these patches are of no help. I'm not sure I understand. (If in zone above 70/bang once unless a new peak is reached while still in that zone)
    • Aug 07 2009 | 3:27 pm
      thank you so much for your help. as i moved forward in the patch and knowing better how the arduino acts, i decided that it's better for precision to have both inputs on, analog and digital, one gives me the voltage, which i convert to dynamics, and the digital for the hit precision. the main problem here is the piezo connected to digital input don't give me only 1 or 0, but a bunch of 0's and 1's all together, it's about 30, but sometimes when you hit more constantly i get more that 30, so i don't really know how much bangs the digital input have. I need some kind of a filter that stops once he gets the first bang or number and starts when another bang/number is received.
      Luis Marques
    • Aug 07 2009 | 3:35 pm
      >>I need some kind of a filter that stops once he gets the first bang or number and starts when another bang/number is received.
      a bit confusion.As this could mean
      N | stop | next N |  start
      which means it never stops.
      you mean 1st value is kept, then nothing for N times Then start again
      !st value , then stop . Start if N is between specific range.
      Anyways, I wish you good luck.
    • Aug 07 2009 | 4:05 pm
      ok, The last is the better i think, only know for sure if i tested, 1st value then stop, only start in a specific range.
    • Aug 09 2009 | 4:43 pm
      IcedDragon wrote on Fri, 07 August 2009 09:27hi, I need some kind of a filter that stops once he gets the first bang or number and starts when another bang/number is received.
    • Aug 09 2009 | 6:11 pm
      change doesn't work because i do want to filter a number but i need to read again the same number...
      Luis Marques
    • Aug 09 2009 | 9:36 pm
      would this very simple solution work? But I'm sure you thought of this.
      sometimes things are so simple, they slips through ideas
    • Aug 12 2009 | 4:24 pm
      If you want the peak to trigger, you can use [peak], for reset use a [trough]. Or just block a retrigger while you play the sample, or block for a specific time. This depends a lot how your input looks like...
      Two versions to try: