unable to compile the same code, that i could earlier - ultrasonic sensor

So i have been uploading this code to run my collision avoidance robot.
I use the command distance = readping () a couple of times, but for some reason the compiler generates the error - 'readPing' was not declared in this scope for the distance = readping() in loop.
can someone explain whats wrong?

robo1.1.ino (3.52 KB)

That code has never compiled and displays a lot more errors than just one.

But if you take out the extra } at then end of loop then it will probably be a lot better.


Go to File -> Preferences and make sure it say ALL after Compiler Warnings.

When you compile your sketch you should see a lot of prints happening in output window at the bottom of the IDE. Start from the top. Identify the error and try to fix it. Often it gives you hints on what could be wrong.

Recompile every time you fixed one error. Sometimes the other errors disappear because they were caused by the errors in your code before.

The error in question tells you that readPing is not valid at the line/block of code. This can have multiple reasons from simple typing error to using a variable outside of where it is valid/visible. This is what scope means.