Capacitive Sensing Piano with Arduino and Max/Msp (HELP!)

min hyuk lee's icon

Hello! :)
I am the person who wanted to create a project using MAX after learning the wonderful effects of MAX/MSP.
but I have a something problem, And I'm having a lot of trouble with these problems. (so sad..)

The current state of my project is that the 'capacitive sensor' works well on the arduino, and this value can be seen on Arduino's serial monitor. And this value (serial) is being matched at Max. However, even when I don't touch the sensor, there is still a problem with sound output, and only one of the three sensors is working.

I hope that sensor values will not be accepted if I do not touch the sensor, and that all three sensors will work on MAX.

And I found and followed a video clip similar to what I wanted to make, but I couldn't do some coding because of poor quality.

-I will attach this video address.
*https://www.youtube.com/watch?v=IVxZqYAbbfk

-I will attached my Arduino code & max/msp coding
*************************


#include <CapacitiveSensor.h> //

int noteDuration = 1000 / 4;
CapacitiveSensor yellowCapSense = CapacitiveSensor(4,8); //
CapacitiveSensor redCapSense = CapacitiveSensor(5,10); // 1M resistor between pins 5 & 10, pin 10 is sensor pin, add a metal surface there
CapacitiveSensor greenCapSense = CapacitiveSensor(6,11); // 1M resistor between pins 6 & 11, pin 11 is sensor pin, add a metal surface there

void setup()
{
Serial.begin(9600);

}

void loop()
{
long yellowCapVal = yellowCapSense.capacitiveSensor(50);
long redCapVal = redCapSense.capacitiveSensor(50);
long greenCapVal = greenCapSense.capacitiveSensor(50);

Serial.print(yellowCapVal); // print sensor1 text
Serial.println(" "); // print sensor1 output

Serial.print(redCapVal); // print sensor2 text
Serial.println(" "); // print sensor2 output

Serial.print(greenCapVal); //print sensor3 text
Serial.println(" "); //print sensor3 output

}

*************************


To sum up, the problem I want to solve is as follows.
1. Only the first sensor works, and I want to operate all three sensors.
2. The first sensor that goes on sound continuously even though it is not touched.

I would like to get a lot of help from you, and I would really appreciate your help. Please help anyone who has ever done such a project or is familiar with it!

Source Audio's icon

Here is help for the trouble that makes You a lot of problems :
change this :
Serial.print(yellowCapVal); // print sensor1 text
Serial.println(" "); // print sensor1 output
Serial.print(redCapVal); // print sensor2 text
Serial.println(" "); // print sensor2 output
Serial.print(greenCapVal); //print sensor3 text
Serial.println(" "); //print sensor3 outpu
t
into :
Serial.print(yellowCapVal); Serial.print(" ");
Serial.print(redCapVal); Serial.print(" ");
Serial.println(greenCapVal);
-------------
The explanation :
println should be implemented only on last item of the serial stream,
otherwise You will allway get a single value output
from zl group in max patch.

min hyuk lee's icon

Thank you so much your opinion!!!! :)
I'll apply what you've told me when I have time!

So, is there any problem with my Max's coding?
In addition, I want to make the piano sound with Max.
Can you tell me if you know any Command and Function In max?

Source Audio's icon

You are welcome.
I can't say if there is any problem with Your max coding,
I have no time to troubleshoot other people's projects.

To make piano sound with max, there are several options,
depending on OS as well.
Built in synth - that microsoft wavetable synth,
on Mac AU DSL synth.
Or use vst object with some plugin.

min hyuk lee's icon

I've modified the aduino coding, as you said, and one of the three pins doesn't work. I'm going to put up the modified code. Can you give me some feedback?

Source Audio's icon

Please post both code and max patch.
No screen shots.
And which pin does not work.