I am in a final stage of my project i want to convert the voltage into refractive index using the slope that i've obtained is plotted on excel sheet.
I used the code below
float Intercept = 4.0927; // -->refer for calibration Value
float Slope = -0.4589; // -->refer for calibration value
float val = 0.0; //variable to store the value coming from the sensor
float Bit = 1023.0; //set value for amount of bits
float volt = 0.0; //set value to store calculated voltage
float SensorData; //float RI=0;
const int SensorPin = A0;
void setup() {
pinMode(A0, INPUT);
Serial.begin(9600);
}
void loop()
{
float Time; // Read and store Sensor data
val = analogRead(A0);
volt = val * (5.0 / 1023.0); //equation to convert incoming value to voltage
float SensorReading= volt*Slope + Intercept; //converts voltage to sensor reading
Serial.print("Refractive Index is:");
Serial.println(SensorReading);
}
Instead of 0 i get a wrong output. I Think there is problem in my code
float c = 4.0927;
float m = -0.4589;
float val = 0.0;
float Bit = 1023.0;
float volt = 0.0;
const int SensorPin = A0;
void setup() {
pinMode(A0, INPUT);
Serial.begin(9600);
}
void loop()
{
val = analogRead(A0);
volt = val*(5.0 / 1023.0); //equation to convert incoming value to voltage
float y= (volt*m + c); //converts voltage to sensor reading
Serial.print("Refractive Index is:");
Serial.println(y);
delay (500);
}
am sorry you mean my username?
it's short form of my full name