Hi,
I am trying to get my FS-N11MN Fiber Optic sensor, which is an intensity-based sensor, to Arduino uno in order to get digital voltage value. I have already set up the circuit for the sensor trough an AC to DC converter and a relay as shown in the picture. Now, I am trying to connect the orange wire of the sensor, which is the analog output wire, to Arduino in order to get the light intensity change in voltage. I have posted the code that I am using for this purpose below, which is pretty simple. However, the serial monitor is sowing millions of values. I have connected the analog output wire of the sensor to pin A0, and grounded the Arduino to sensor's -V. Can you please let me know what I am doing wrong here in case of wiring and/or coding?
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading to a voltage (0 - 5v):
float voltage = sensorValue * (5.0 / 1023.0);
// print out th value you read:
Serial.println(voltage);
}


