This is the code you were asked to post but didn't. We ask this because many menbers, myself included, use mobile devices and they can't read .ino files even though basically they are text. So you have to wait until some one is using a laptop before they can see the code.
/*
Arduino Organ by pollux labs, 2020
More projects and tutorials: https://polluxlabs.net
*/
// Import the CapacitiveSensor Library.
#include <CapacitiveSensor.h>
//Set sensor sensitivity
int sensitivity = 3000;
// Set the Send Pin & Receive Pin.
CapacitiveSensor cs_2_4 = CapacitiveSensor(2, 4);
CapacitiveSensor cs_2_5 = CapacitiveSensor(2, 5);
CapacitiveSensor cs_2_6 = CapacitiveSensor(2, 6);
CapacitiveSensor cs_2_7 = CapacitiveSensor(2, 7);
CapacitiveSensor cs_2_8 = CapacitiveSensor(2, 8);
void setup()
{
Serial.begin(9600);
}
void loop()
{
long sensor4 = cs_2_4.capacitiveSensor(sensitivity);
long sensor5 = cs_2_5.capacitiveSensor(sensitivity);
long sensor6 = cs_2_6.capacitiveSensor(sensitivity);
long sensor7 = cs_2_7.capacitiveSensor(sensitivity);
long sensor8 = cs_2_8.capacitiveSensor(sensitivity);
Serial.print(sensor4);
Serial.print(",");
Serial.print(sensor5);
Serial.print(",");
Serial.print(sensor6);
Serial.print(",");
Serial.print(sensor7);
Serial.print(",");
Serial.println(sensor8);
delay(500);
}
You may want to read this before you proceed:-
how to get the best out of this forum
You never said anything, which is annoying. You don't just have to be doing a course in computer science, it could be electronic engineering, physics or even art. I am a retired University lecturer (Professor in U.S. speak) and that is what I would expect no matter what your core discipline.
Now what you need to do is to run this code and see what numbers you get from it. Then you can workout what is the best threshold value for each sensor. That is a value that above which you want to trigger the sound. Each sensor will then have its own trigger level. These readings will change depending on how damp the soil is.
So then you take that code and modify it so that you only print out the sensor's number when you see it above this threshold. Keeping things simply you can use just a repeating of statements for this, like this:-
if(sensor4 > threshold4) print(4);
if(sensor5> threshold5) print(5);
if(sensor6 > threshold6) print(6);
if(sensor7 > threshold7) print(7);
if(sensor8 > threshold8) print(8);
Of course you should define these threshold variables as long variable before the setup function.
Note this will look rubbish in the serial monitor because there is no gaps or anything so it is just a long string of numbers, but that is not important because you will be reading them in Processing. What you do there is just look at the single byte that arrives in the serial port, and, if that sample is not playing you start it off playing.
Have you got any processing code yet? If so please post it correctly.