So I made an equation to get a very close match to the actual GP2Y0A02YK0F sharp ir sensor voltage curve. It is:

y=(0.011x-sqrt(2.25)-0.16)^2+0.45

where y is volts and x is distance. Trying to make it into x= form, I got this:

x=(1000*sqrt(y+2.3056))/11

So then i make an Arduino script that looks like this:

"analogRead(0)/694" in line 14 is based on peak voltage outputs. Any ideas?

y=(0.011x-sqrt(2.25)-0.16)^2+0.45

where y is volts and x is distance. Trying to make it into x= form, I got this:

x=(1000*sqrt(y+2.3056))/11

So then i make an Arduino script that looks like this:

#include <SoftwareSerial.h>And it gives me junk data. The 694 in

#include <math.h>

void setup(){

int IRpin=0;

Serial.begin(9600);

Serial.println("Hello world!");

delay(1500);

Serial.println("This is a test.");

delay(3000);

}

void loop(){

float volts = analogRead(0)/694;

float distance_a = (1000*(sqrt(volts+2.3056)))/11;

float distance_b = (1000*(sqrt(volts+2.3056)))/11;

float distance_c = (1000*(sqrt(volts+2.3056)))/11;

float distance_d = (1000*(sqrt(volts+2.3056)))/11;

float distance_e = (1000*(sqrt(volts+2.3056)))/11;

float average_distance = (distance_a+distance_b+distance_c+distance_d+distance_e)/5;

Serial.println(average_distance);

Serial.println(volts);

delay(1000);

}

"analogRead(0)/694" in line 14 is based on peak voltage outputs. Any ideas?

"What's a microcontroller? You mean an Arduino?"