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!
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!