int sensorPin = A0; // select the input pin for the wires for Galvanic Skin Response int ledPin = 11; // select the pin for the LED int sensorValue = 0; // variable to store the value coming from the sensor int lowestVal = 1023; int highestVal = 0; int pwmVal = 0; void setup() { // declare the ledPin as an OUTPUT: pinMode(ledPin, OUTPUT); Serial.begin(9600); pinMode(13, OUTPUT); digitalWrite(13, HIGH); for(int i = 0; i < 6000; i++){ // read the current value from the GSR sensorValue = analogRead(sensorPin); //check to see if the value is greater than highestVal ... if( sensorValue > highestVal){ highestVal = sensorValue; } // or less than lowestVal if( sensorValue < lowestVal){ lowestVal = sensorValue; } delay(1); } digitalWrite(13, LOW); } void loop() { // read the value from the sensor: sensorValue = analogRead(sensorPin); Serial.println( sensorValue ); sensorValue = constrain(sensorValue, lowestVal, highestVal); pwmVal = map( sensorValue, lowestVal, highestVal, 0, 255); analogWrite(ledPin, pwmVal); }