Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HC_SR04_Ultrasonic_Library PinDetect
radar.h@0:23a36e52a5fa, 2018-06-28 (annotated)
- Committer:
- vhx
- Date:
- Thu Jun 28 15:33:29 2018 +0000
- Revision:
- 0:23a36e52a5fa
Nucleo ultrasonic radar.; TODO: Sending data over the net.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| vhx | 0:23a36e52a5fa | 1 | #ifndef _RADAR_H_ |
| vhx | 0:23a36e52a5fa | 2 | #define _RADAR_H_ |
| vhx | 0:23a36e52a5fa | 3 | // must import HC_SR04_Ultrasonic_Library |
| vhx | 0:23a36e52a5fa | 4 | // https://os.mbed.com/components/HC-SR04/ |
| vhx | 0:23a36e52a5fa | 5 | #include <ultrasonic.h> |
| vhx | 0:23a36e52a5fa | 6 | |
| vhx | 0:23a36e52a5fa | 7 | /* Range enum */ |
| vhx | 0:23a36e52a5fa | 8 | enum { |
| vhx | 0:23a36e52a5fa | 9 | RANGE_NONE=0, |
| vhx | 0:23a36e52a5fa | 10 | RANGE_FAR, |
| vhx | 0:23a36e52a5fa | 11 | RANGE_MID, |
| vhx | 0:23a36e52a5fa | 12 | RANGE_CLOSE, |
| vhx | 0:23a36e52a5fa | 13 | RANGE_MAX |
| vhx | 0:23a36e52a5fa | 14 | }; |
| vhx | 0:23a36e52a5fa | 15 | |
| vhx | 0:23a36e52a5fa | 16 | extern void radar(void); |
| vhx | 0:23a36e52a5fa | 17 | |
| vhx | 0:23a36e52a5fa | 18 | |
| vhx | 0:23a36e52a5fa | 19 | /* Globals */ |
| vhx | 0:23a36e52a5fa | 20 | // Global position variable |
| vhx | 0:23a36e52a5fa | 21 | extern int volatile position; |
| vhx | 0:23a36e52a5fa | 22 | //Set the trigger pin to PC_8 and the echo pin to PC_6 |
| vhx | 0:23a36e52a5fa | 23 | //have updates every .1 seconds and a timeout after 1 |
| vhx | 0:23a36e52a5fa | 24 | //second, and call dist when the distance changes |
| vhx | 0:23a36e52a5fa | 25 | extern ultrasonic mu; |
| vhx | 0:23a36e52a5fa | 26 | |
| vhx | 0:23a36e52a5fa | 27 | extern DigitalOut led1; |
| vhx | 0:23a36e52a5fa | 28 | extern DigitalOut led2; |
| vhx | 0:23a36e52a5fa | 29 | extern DigitalOut led3; |
| vhx | 0:23a36e52a5fa | 30 | |
| vhx | 0:23a36e52a5fa | 31 | #endif //_RADAR_H_ |