Sorry but looking at it you could miss those resistors out altogether.
That is the problem with schematics in your mind they don't always work.
Now I see it as a diagram there is no way you could get a short on the power supply. So go with the original diagram you had. You might want to reduce the value of R1 if you get interference pick up problems causing false triggering.
reducing R1 will cause stronger pull-up to +5V right? what is the disadvantage of it? only consuming more current?
At the end I will use arduino only of the interface to get the Analog values into Max/MSP
here is my complete arduino code:
Any thing you might change?
int sensorPin = A0;
uint16_t sensorValue = 0; // variable to store the value coming from the sensor
uint16_t psensorValue = 0;
unsigned long pMillis = 0;
uint16_t interval = 50;
void sensor();
void setup()
{
Serial.begin(9600);
}
void loop()
{
sensor();
}
void sensor()
{
//read every x interval//
if(millis() - pMillis >= interval)
{
pMillis = millis();
sensorValue = analogRead(sensorPin);
// don't print repeatition of numbers//
if(sensorValue != psensorValue)
{
Serial.println(sensorValue);
psensorValue = sensorValue;
}
}
}
The disadvantage of the stronger pull up is that it produces a very slightly smaller signal from a given holding hand resistance. The current change is insignificant.
This is a pre definition of a function, this is usual in C but in the Arduino these are generated automatically, so there is no need to include the line.
Make that an unsigned long.
This is unlikely to be successful as the reading will have at least a +/- least significant noise reading on it. That is just the nature of how all A/D work. So you are better putting something to detect a change that's bigger. Define a variable and call it threshold and give it a value, say 8.
So that all the data types in the expression of of the same type.
The abs function call returns the absolute value, that means if that expression works out at 8 then it returns 8 and if the expression is -8 it returns 8. So the > threshold works on both rising values and falling values.
Filter? Why?
A better name would be delta, meaning change. You are free to call variables anything you want but it helps enormously if you use meaningful names.
Where is the threshold value used?
Once you return from a function that last line can never be executed, so swap them around.
That second code is printing out values every 0.1 second, so not all the time, if you want it to print less often make the interval longer.
No because most people have shoes on there feet and that prevents them making electrical connections with anything electric on the floor. Those that don't have shoes tend to build up a layer of dirt that acts as an insulator. You would have to arrange that only one of the two people would make contact with this mat anyway.
It is the other way round, open circuit allows the pull up to give a reading of 1023 and a short circuit which you will never get holding hands gives a reading of 0.
Yep, I was thinking about that. So My best solution for that project still will be the wire between the two persons and arduino analog pin and ground.
Regarding the dust - I did not know it can act as an insulator. this is why dust is better off in electrical circuits?
Yes, so if I decrease the value of R1 and the body resistance (aka R2 in voltage divider) stay the same, the output voltage will increase towards +5V (1023). If I increase R1 and the body resistance stay the same, the output voltage will decrease towards 0V isn't it?
another question I have in mind - assuming 5V and at-least 10M Resistor between the 5V through the person body to ground, I can know that no more than 0.0000005A will be flow through the human body. is there any value considering my system design It could make electricity shock? at what current it can be an dangerous?
You would have to significantly reduce the contact resistance between the people and the electronics. The sort of thing that involves an electrode that breaks the skin and connects directly to the blood. The hands too would need cuts in them so that it mingles between the two people holding hands. A dangerous level is reached when you can push about 10mA across the heart. It is not going to happen in the normal course of events. But if I were to say it is perfectly safe some one would come along and describe what I have said above.
One thing to consider: if this is permanently powered via the mains and a lightning strike happens nearby it could be dangerous.
I would suggest this should be battery powered and fully isolated from any building metalwork to become intrinsically safe from this scenario, or at least you follow the safety precautions used for medical electronic devices.
And of course it goes without saying that any mains supply used should not be unbranded or counterfeit or without UL and similar ratings indicating full safety testing and approval has been performed.
What do you mean by power via the mains? The Arduino itself will be powered by a computer which will be power by the mains - Is that setup will be fine?
All data receiving by the Arduino will be send to MaxMSP via the usb connection (Serial) so Arduino itself will get is power from the computer.
You can always rely on @MarkT to spot the real danger. Yes your proposed set up is directly connected to the mains. So in the event of a lightning strike in the building and your computer is located next to the metal strip from a lightning conductor then this is a danger.
I was once working in factory an Old Mill in Yorkshire and we had a lightning strike, in fact several strikes. Only one computer exploded and no one was hurt, but the engineer wasn't working on it at the time.so, yes that could happen but it is not too likely. Just unplug the computer if there is a lightning storm or don't have the installation close to the wall of the building where the lightning conductor's strip is running.
quoting @DVDdoug from the above topic: "Put a capacitor (maybe 0.1uF) in parallel with the resistor to filter-out noise and stabilise the readings reading."
What is that noise that the capacitor is filtering in order to stabilise the reading? I indeed notice the help of adding that 0.1uF cap in parallel with the 10M resistor. I just asking how/why it does what it does? I also experiment changing the value of the cap to 1uF and the reading become even more stable. What could be the disadvantage of a higher value cap? slewing between one value to the next?
In today's world electrical noise is all around us. It comes from the mains, from the light fittings, especially fluorescent lights, dimmed LEDs and electric motors are the main culprits. But also thermistors tripping in and out. Even passing motor bikes and the radio of taxis can all generate interference.
The disadvantage of a too aggressive filter is that it can slow down the signals as well.
If the variable is declared outside of any function is is called global, so you just use it wherever you want, it will contain the last value until you change it.
You return the value correctly, but he serial print swallows the number.
So you could use
Int sensorReturn;
void loop()
{
sensorReturn = sensor();
Serial.println(sensorReturn);
}