Re: Could someone look at this code?
It's very hard to understand what your code is trying to do. So I am trying to figure out what you want to do from your description. If I understand correctly, are you trying to use a sonar sensor to detect whether you are aligned with the center goal? It looks like you are mounting the sonar sensor to the side so you would continue to go forward until the sonar sensor reads a value indicating the center goal is directly to your (left or right) side. You continue to go forward until the sonar sensor passes the center goal and reads a much bigger value, then you go back. If that's the case, you don't need an array. You can do something like the following.