Seeeduino Stalker Sketches

Hi CRS8291,

I have now got the sensor working correctly with the test code below. Unfortunately I don't understand, at all, how the digital pin 3 is assigned to the sensor in your code and was wondering if you might be able to help me merge the two to get my analog sensor working in your sketch?

int ledPin =  13;    // LED connected to digital pin 13
int sensorPin = 1;   // SFH203FA connected to analog pin 1
int sensorState = 0;



void setup()   {
  // initialize the digital pin as an output:
  pinMode(ledPin, OUTPUT);
  pinMode(sensorPin, INPUT);
 Serial.begin(9600);
}

void loop(){
  // read the state of the sensor value:
  sensorState = analogRead(sensorPin);

  // check if the sensor is receiving.
  // if it is, the ledState is HIGH - have guessed a theshhold value of 100?
  if (sensorState > 100) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  }
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
  Serial.println(sensorState);
}