Uses 2 HC-SR04 ultrasonic modules to steer the RenBuggy away from obstacles. Renishaw Team page fork.
Dependencies: mbed
Fork of RenBuggy_Ultrasonic by
ultrasonic_buggy.h@0:fbceffb594b6, 2016-07-14 (annotated)
- Committer:
- RenBuggy
- Date:
- Thu Jul 14 12:58:48 2016 +0000
- Revision:
- 0:fbceffb594b6
- Child:
- 1:80c2ef16a42f
.
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:fbceffb594b6 | 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 | 0:fbceffb594b6 | 31 | extern void forward(float); //Move the buggy forward for (float) seconds |
RenBuggy | 0:fbceffb594b6 | 32 | extern void left(float); //Turn left for (float) seconds |
RenBuggy | 0:fbceffb594b6 | 33 | extern void right(float); //Turn right for (float) seconds |
RenBuggy | 0:fbceffb594b6 | 34 | extern void hold(float); //Hold the buggy in an idle state for (float) seconds |
RenBuggy | 0:fbceffb594b6 | 35 | extern void stop(); //Stop all motors |
RenBuggy | 0:fbceffb594b6 | 36 | |
RenBuggy | 0:fbceffb594b6 | 37 | extern float getDistance_l(void); |
RenBuggy | 0:fbceffb594b6 | 38 | extern float getDistance_r(void); |
RenBuggy | 0:fbceffb594b6 | 39 | void resetSR04(void); |
RenBuggy | 0:fbceffb594b6 | 40 | |
RenBuggy | 0:fbceffb594b6 | 41 | #endif // BUGGY_FUNCTIONS_H |