Galvanic Skin Response with the Arduino Uno

Hi,

I’m kinda new to physical computing, but I’m doing a module at uni and this is my first independent project!
I am stuck on something that is probably quite simple to advanced and intermediate physical computing people, But here goes…

I am trying to do a simple test with my new Galvanic skin response, but can’t figure out why the LED won’t light up when it detects a change? I am not sure I wired it properly but have tried numerous ways and still no light. Tested to see if the LED is broken, which it isn’t all parts that I am using are in full working order.

I would appreciate if someone took the time to look at my board and help me with the circuitry. If I can figure it out and understand it then I can move on to bigger things, but this is really bugging me.

I have attached the code, I hope someone is kind enough to help before I pull my hair out! :stuck_out_tongue_closed_eyes:

const int LED = 13; // LED in pin 13
const int GSR=A2; // GSR connected to analog 2
int threshold=0; // Very low threshold 
int sensorValue; // This is the output

void setup(){
  long sum = 0; //start the detection at 0
  Serial.begin(9600); //Serial code begins at 9600
  pinMode(LED,OUTPUT); // The led will light up as it is an output value
  digitalWrite(LED,LOW); // The LED with be low
  delay(1000); // Quick
  
  for(int i=0;i<500;i++) //if there is more than 500 then read the value 
  {                      //from the GSR and add to it every 5 seconds
  sensorValue=analogRead(GSR);
  sum += sensorValue;
  delay(5);
  }
  threshold = sum/500;
   Serial.print("threshold ="); // Will output the threshold number
   Serial.println(threshold);
  }

void loop(){
  int temp; //temperature variable
  sensorValue=analogRead(GSR); //read the values from the GSR
  Serial.print("sensorValue="); // Output the values from the GSR
  Serial.println(sensorValue);
  temp = threshold - sensorValue; //Equation for the temp is threshold - sensorValue
  if(abs(temp)>60) // if the absolute temperature is more than 60
  {
    sensorValue=analogRead(GSR); //then the sensorValue is whatever the GSR reads 
    temp = threshold - sensorValue;
    if(abs(temp)>60){
    digitalWrite(LED,HIGH); //The LED output increases and is HIGH
    Serial.println("Emotion Changes Detected!"); //prints this in serial
    delay(3000); // delay
    digitalWrite(LED,LOW); // when the person's state changes, it goes back to the orignal values
    delay(1000);
  }
 }
}

I have so far wired up a 220k ohm to the ground and the shorter leg to the cathode, D13 on Arduino to the anode of the LED and the GSR, I have attached the VCC to 5v, ground to ground and signal to analog 2. I don’t know why the LED won’t light up. Everything else works!

What is "my new Galvanic skin response"?
What is your circuit, please draw a diagram of how you have wired it up.

Your code comments are way out which can indicate faulty thinking.

What do you get as an output from those serial prints?

Grumpy_Mike:
What is "my new Galvanic skin response"?
What is your circuit, please draw a diagram of how you have wired it up.

Your code comments are way out which can indicate faulty thinking.

What do you get as an output from those serial prints?

Please can I email you? I cannot send you anything here it keeps giving me an error :frowning:

Here are a few pics

it keeps giving me an error

Is that because your pictures are too big? Try resizing them, most graphics programs will do that. We don't need anything more 1000 pixels.
If you are posting serial monitor outputs, don't post screen dumps, just copy the text from the serial monitor window and paste it into your reply post.

Probably worth reading this as well for other tips about asking questions How to use this forum

I hope you can see the pics

2 more

So thanks for the pictures but this does not address the “What is your circuit, please draw a diagram of how you have wired it up.” A circuit diagram is ever so much more clear than a photo graph.
I can see on thing though, you said “I have so far wired up a 220k ohm to the ground” which is not what you have done, you have done it right but said it wrong. You have used a 220R resistor not a 220K. If you actually use a 220K you would not see the LED light up.

Now this does not help me in finding out what is wrong because you have not answered “What do you get as an output from those serial prints?”. Those print statements are for debugging or fault finding. It will tell you what the threshold is that you have calculated, it is possible that this is way bigger than you can actually get 60 more than. So it is vital to know what the code outputs.

I have not got your hardware so I can not see for myself. Only you can tell me this.

You are averaging 500 readings, this potentially produces a number way too big to fit into an int variable. It will overflow. The most you can take is 32 numbers, unless you use a long int variable type.