hey everybody! I am building an arduino based robot, and need to collect data from 3 Ultrasonic Sensors(parallax ping to be specific), and am trying to get a measureDistance function to work. The way I would like to do so is to be able to just have measureDistance(leftUSpin) to return the value of the left US sensor, measureDistance(rightUSpin) to return the right, etc.
The problem is, that I cannot get the actual function part to work. The rest of the code, when run outside of the function, works perfectly.
Here are the important bits of the code
int frontUSpin=2; //pin assignment
int frontUSdist; //distance var in cm
unsigned long pulseduration=0;
USdist = int(pulseduration/29);
Serial.print("Distance - ");
Also, here is the error output:
ffrobot:10: error: 'USside' was not declared in this scope
ffrobot:36: error: redefinition of 'int measureDistance'
ffrobot:10: error: 'int measureDistance' previously defined here
ffrobot.cpp: In function 'void loop()':
ffrobot:67: error: 'measureDistance' cannot be used as a function
Any help would be greatly appreciated!