Arduino, Processing and 2 HC-SR04 Ultrasonic Sensor problems. Please help....

if (d1>=dist){
   currentState=currentState +1;

else
    if (d2>=dist){
      currentState=currentState -1;
    }

I'm guessing that the error message (which you didn't post) is something like "else without previous if", which is why I asked about the missing braces.

Please read my earlier definition of working vs. compiling.