Uses 2 HC-SR04 ultrasonic modules to steer the RenBuggy away from obstacles. Renishaw Team page fork.

Dependencies:   mbed

Fork of RenBuggy_Ultrasonic by Ren Buggy

Committer:
RenBuggy
Date:
Mon Jul 18 10:00:29 2016 +0000
Revision:
1:80c2ef16a42f
Parent:
0:fbceffb594b6
First working revision, uses 2 sensors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RenBuggy 0:fbceffb594b6 1 /*********************************************************
RenBuggy 0:fbceffb594b6 2 *buggy_functions.h *
RenBuggy 0:fbceffb594b6 3 *Author: Elijah Orr & Dan Argust *
RenBuggy 0:fbceffb594b6 4 * *
RenBuggy 0:fbceffb594b6 5 *A library of functions that can be used to control the *
RenBuggy 0:fbceffb594b6 6 *RenBuggy. *
RenBuggy 0:fbceffb594b6 7 *********************************************************/
RenBuggy 0:fbceffb594b6 8
RenBuggy 0:fbceffb594b6 9 /* include guards are used to prevent problems caused by
RenBuggy 0:fbceffb594b6 10 multiple definitions */
RenBuggy 0:fbceffb594b6 11 #ifndef BUGGY_FUNCTIONS_H
RenBuggy 0:fbceffb594b6 12 #define BUGGY_FUNCTIONS_H
RenBuggy 0:fbceffb594b6 13
RenBuggy 0:fbceffb594b6 14 /* mbed.h must be included in this file also */
RenBuggy 0:fbceffb594b6 15 #include "mbed.h"
RenBuggy 0:fbceffb594b6 16
RenBuggy 0:fbceffb594b6 17 /* #define LeftMotorPin p5 tells the preprocessor to replace
RenBuggy 0:fbceffb594b6 18 any mention of LeftMotorPin with p5 etc. */
RenBuggy 0:fbceffb594b6 19 #define LEFT_MOTOR_PIN P0_9
RenBuggy 0:fbceffb594b6 20 #define RIGHT_MOTOR_PIN P0_8
RenBuggy 0:fbceffb594b6 21
RenBuggy 0:fbceffb594b6 22 /* define pins to be used to operate the ultrasonic */
RenBuggy 0:fbceffb594b6 23 #define TRIGGER_PIN P0_11
RenBuggy 0:fbceffb594b6 24 #define LEFT_ECHO_PIN P1_20
RenBuggy 0:fbceffb594b6 25 #define RIGHT_ECHO_PIN P0_12
RenBuggy 0:fbceffb594b6 26
RenBuggy 1:80c2ef16a42f 27 #define SPEED_OF_SOUND 340 //speed of sound =~340m/s at standard conditions
RenBuggy 0:fbceffb594b6 28
RenBuggy 0:fbceffb594b6 29 /* these are function prototypes that declare all the functions
RenBuggy 0:fbceffb594b6 30 in the library.*/
RenBuggy 1:80c2ef16a42f 31 extern void forward(float); //Move the buggy forward for (float) seconds
RenBuggy 1:80c2ef16a42f 32 extern void left(float); //Turn left for (float) seconds
RenBuggy 1:80c2ef16a42f 33 extern void right(float); //Turn right for (float) seconds
RenBuggy 1:80c2ef16a42f 34 extern void hold(float); //Hold the buggy in an idle state for (float) seconds
RenBuggy 1:80c2ef16a42f 35 extern void stop(); //Stop all motors
RenBuggy 0:fbceffb594b6 36
RenBuggy 1:80c2ef16a42f 37 extern float getDistance_l(void); //get a distance reading in metres from the left sensor
RenBuggy 1:80c2ef16a42f 38 extern float getDistance_r(void); //get a distance reading in metres from the right sensor
RenBuggy 1:80c2ef16a42f 39 void resetSR04(void); //reset both ultrasonic modules
RenBuggy 0:fbceffb594b6 40
RenBuggy 0:fbceffb594b6 41 #endif // BUGGY_FUNCTIONS_H