Well, I accidentally uploaded some code that doesn’t even compile. I am very, very sorry about that.
This code, however, not only works but also works well:
int x, x1, x2;
x1 = SensorRaw(S2);
x2 = SensorRaw(S2);
x = (x1 + x2)/2;
OnFwd(OUT_BC, ((1023 – ((x – ((GetOutput(OUT_B, RotationCount) / 128)) – (SensorRaw(S2)))) * 4) ^ (1/2)));
While I’m still tweaking some of the values (128 and 4, to be specific), this works better than I had ever imagined, for a few reasons. First, I am not a programmer; I am a newbie. Second, The light sensor programs I’ve seen and ran before didn’t work as well, but they were implementing full PID so they ran a little slower. Third, I’ve never done anything other than just P before, so adding my version of I was…. frustrating.
P.S. This setup is for a Light Sensor placed near the robot. A new one with the sensor farther away is in the works as well.