Go Down

Topic: AFMotor example explanation (Read 382 times) previous topic - next topic

Marciokoko

Im looking at an instructables tutorial on a rover using an ultrasonic sensor.

I've been looking over the code to try and understand it fully before implementing it or tweaking it.

The link is here:

http://www.instructables.com/id/Arduino-HC-SR04-Ultrasonic-Rover/

I've boiled the code down to:

Code: [Select]
checkPath()
-Sweeps left to right 144 a 36
-checkForward() ensures we are facing front
-readPing()
-If distance < 10cm = checkCourse and exit sweep loop
-If distance < 20cm = changePath

setCourse() - If maxAngle < 90, turnRight() & vv
checkCourse() - reverse, stop, setCourse()
changePath() - If pos < 90, veerLeft() & vv
readPing() - retorna distancia
checkForward() & checkBackward()
moveForward() & moveBackward - faces front & accelerates slowly
moveStop() - all stops
turnRight() & turnLeft() - ??
veerRight() & veerLeft() - ??


Im confused as to what turnRight/Left() and veerRight/Left do?

It would appear turnRight actually makes the car spin in place as it turns right.  But then veerRight seems quite similar.  Then I noticed they are each called from changeCourse() and changePath() where changeCourse() calls turnR/L and changePath() calls veerR/L.


Go Up