Fox Red Labs / Builds / Motor control, power and sensing
Parking sensor that beeps faster as you get close
An RCWL-1601 ultrasonic sensor and a buzzer; the closer you get, the faster it beeps and the serial port prints the distance.
MediumWiring neededOne sitting
You learn: Timing an echo pulse with a timer capture, and turning distance into beep rate.
All 8 wiring steps
- 1Breadboard and groundSet the breadboard on the right and run a black wire from J2 pin 20 (GND) to the top blue rail. A rail is a long strip of holes joined end to end.Black wire from J2 pin 20 (GND) to the top blue rail.
- 23.3 V to the red railA red wire from J1 pin 1 (3V3) to the top red rail. The RCWL-1601 works from 3.3 V, so its pins are safe for the chip. The HC-SR04 needs 5 V and a divider on its echo wire; this build uses the RCWL-1601 to avoid that.Red wire from J1 pin 1 (3V3) to the top red rail.
- 3The ranger on its headerPush the ranger's four pins into row g, holes g10 to g13, with the two round transducers facing the LaunchPad. The pins go GND in g10, ECHO in g11, TRIG in g12 and VCC in g13.The ranger stands upright, its four pins in g10 to g13. Read the letters on its back to confirm the order.
- 4Power and groundA red wire from j13 to the red rail and a black wire from j10 to the blue rail.Red at the VCC column, black at the GND column.
- 5Trigger and echoA yellow wire from the TRIG column to J4 pin 35 (PB5) and a green wire from the ECHO column to J4 pin 36 (PB4). The chip raises TRIG for 10 microseconds to start a ping. ECHO stays high for as long as the sound took to go out and come back, and the chip times that.Yellow to J4 pin 35 (PB5), green to J4 pin 36 (PB4).
- 6Resistor and buzzerA 330 ohm resistor (orange, orange, brown) into h19 and h22, the buzzer's plus leg into f22 and the other leg into f25. The kit's passive buzzer is a magnetic one with a few ohms of coil; straight on a pin it would draw more than an MSPM0 pin may give, so a 330 ohm resistor goes in line.The buzzer stands over f22 and f25, its resistor beside it in row h.
- 7Buzzer signal and groundA purple wire from j19 to J2 pin 14 (PB7) and a black wire from j25 to the blue rail.Purple to J2 pin 14 (PB7), black to the ground rail.
- 8Run itRun the parking program. Hold your hand 30 cm from the ranger, then move it closer: the beeps speed up as the distance falls.Far away: a slow beep. Close: a fast beep. Under about 5 cm: a steady tone.
Every wire and signal, far end to board end
| Wire | From | To | Step |
|---|---|---|---|
| Ground rail | Ground rail (blue, hole 2) | J2 pin 20 (GND) | 1 |
| 3.3 V rail | 3V3 rail (red, hole 2) | J1 pin 1 (3V3) | 2 |
| Ranger GND | Ranger GND, breadboard j10 | Ground rail | 4 |
| Ranger VCC | Ranger VCC, breadboard j13 | 3V3 rail | 4 |
| Ranger TRIG | Ranger TRIG, breadboard j12 | J4 pin 35 (PB5) | 5 |
| Ranger ECHO | Ranger ECHO, breadboard j11 | J4 pin 36 (PB4) | 5 |
| Buzzer signal | Buzzer resistor, breadboard j19 | J2 pin 14 (PB7) | 7 |
| Buzzer to ground | Buzzer minus, breadboard j25 | Ground rail | 7 |
| Signal | Part pin | LaunchPad pin | What the program does with it |
|---|---|---|---|
| TRIG | Ranger TRIG, hole g12 | J4 pin 35 (PB5) | Digital output |
| ECHO | Ranger ECHO, hole g11 | J4 pin 36 (PB4) | Digital input, internal pull-up |
| BUZZ | Buzzer through 330 ohm, hole j19 | J2 pin 14 (PB7) | Timer PWM output |
| Ranger power | VCC and GND pins | J1 pin 1 (3V3), J2 pin 20 (GND) | 3.3 V supply for the RCWL-1601 |
Wire an ultrasonic ranger and a buzzer
All 8 wiring steps
- 1Breadboard and groundSet the breadboard on the right and run a black wire from J2 pin 20 (GND) to the top blue rail. A rail is a long strip of holes joined end to end.Black wire from J2 pin 20 (GND) to the top blue rail.
- 23.3 V to the red railA red wire from J1 pin 1 (3V3) to the top red rail. The RCWL-1601 works from 3.3 V, so its pins are safe for the chip. The HC-SR04 needs 5 V and a divider on its echo wire; this build uses the RCWL-1601 to avoid that.Red wire from J1 pin 1 (3V3) to the top red rail.
- 3The ranger on its headerPush the ranger's four pins into row g, holes g10 to g13, with the two round transducers facing the LaunchPad. The pins go GND in g10, ECHO in g11, TRIG in g12 and VCC in g13.The ranger stands upright, its four pins in g10 to g13. Read the letters on its back to confirm the order.
- 4Power and groundA red wire from j13 to the red rail and a black wire from j10 to the blue rail.Red at the VCC column, black at the GND column.
- 5Trigger and echoA yellow wire from the TRIG column to J4 pin 35 (PB13) and a green wire from the ECHO column to J4 pin 36 (PB20). The chip raises TRIG for 10 microseconds to start a ping. ECHO stays high for as long as the sound took to go out and come back, and the chip times that.Yellow to J4 pin 35 (PB13), green to J4 pin 36 (PB20).
- 6Resistor and buzzerA 330 ohm resistor (orange, orange, brown) into h19 and h22, the buzzer's plus leg into f22 and the other leg into f25. The kit's passive buzzer is a magnetic one with a few ohms of coil; straight on a pin it would draw more than an MSPM0 pin may give, so a 330 ohm resistor goes in line.The buzzer stands over f22 and f25, its resistor beside it in row h.
- 7Buzzer signal and groundA purple wire from j19 to J2 pin 14 (PB7) and a black wire from j25 to the blue rail.Purple to J2 pin 14 (PB7), black to the ground rail.
- 8Run itRun the parking program. Hold your hand 30 cm from the ranger, then move it closer: the beeps speed up as the distance falls.Far away: a slow beep. Close: a fast beep. Under about 5 cm: a steady tone.
Every wire and signal, far end to board end
| Wire | From | To | Step |
|---|---|---|---|
| Ground rail | Ground rail (blue, hole 2) | J2 pin 20 (GND) | 1 |
| 3.3 V rail | 3V3 rail (red, hole 2) | J1 pin 1 (3V3) | 2 |
| Ranger GND | Ranger GND, breadboard j10 | Ground rail | 4 |
| Ranger VCC | Ranger VCC, breadboard j13 | 3V3 rail | 4 |
| Ranger TRIG | Ranger TRIG, breadboard j12 | J4 pin 35 (PB13) | 5 |
| Ranger ECHO | Ranger ECHO, breadboard j11 | J4 pin 36 (PB20) | 5 |
| Buzzer signal | Buzzer resistor, breadboard j19 | J2 pin 14 (PB7) | 7 |
| Buzzer to ground | Buzzer minus, breadboard j25 | Ground rail | 7 |
| Signal | Part pin | LaunchPad pin | What the program does with it |
|---|---|---|---|
| TRIG | Ranger TRIG, hole g12 | J4 pin 35 (PB13) | Digital output |
| ECHO | Ranger ECHO, hole g11 | J4 pin 36 (PB20) | Digital input, internal pull-up |
| BUZZ | Buzzer through 330 ohm, hole j19 | J2 pin 14 (PB7) | Timer PWM output |
| Ranger power | VCC and GND pins | J1 pin 1 (3V3), J2 pin 20 (GND) | 3.3 V supply for the RCWL-1601 |
Wire an ultrasonic ranger and a buzzer
What you need
LP-MSPM0G3519On Linux or WindowsThe steps were recorded on a Mac; paths and port names in them are the Mac ones.
macOS (recorded)
- TI's tools
/Applications/ti, or~/ti- Serial port
/dev/cu.usbmodem<serial>1- Probe access
- nothing to do
Linux
- TI's tools
~/ti(also searched:/opt/ti)- Serial port
/dev/ttyACM0(by name:/dev/serial/by-id/*<serial>*-if00*)- Probe access
- one udev rule, how
Windows
- TI's tools
C:\ti(also searched:%USERPROFILE%\ti)- Serial port
COM<n>, named "XDS110 Class Application/User UART" in Device Manager- Probe access
- the XDS110 USB driver from UniFlash or CCStudio
Your probe's serial on any system: python3 tools/frl/frl.py detect. Not run on a board under Linux or Windows. Everything else that differs: the full table.
LP-MSPM0G3507On Linux or WindowsThe steps were recorded on a Mac; paths and port names in them are the Mac ones.
macOS (recorded)
- TI's tools
/Applications/ti, or~/ti- Serial port
/dev/cu.usbmodem<serial>1- Probe access
- nothing to do
Linux
- TI's tools
~/ti(also searched:/opt/ti)- Serial port
/dev/ttyACM0(by name:/dev/serial/by-id/*<serial>*-if00*)- Probe access
- one udev rule, how
Windows
- TI's tools
C:\ti(also searched:%USERPROFILE%\ti)- Serial port
COM<n>, named "XDS110 Class Application/User UART" in Device Manager- Probe access
- the XDS110 USB driver from UniFlash or CCStudio
Your probe's serial on any system: python3 tools/frl/frl.py detect. Not run on a board under Linux or Windows. Everything else that differs: the full table.
What happens inside the chip
Parking sensor
Wiring. Sensor TRIG to J4 pin 35 (PB5), ECHO to J4 pin 36 (PB4), VCC to J1 pin 1 (3V3), GND to J2 pin 20 (GND). Buzzer to J2 pin 14 (PB7), its other leg to GND.
Tap a block or a step to follow one job.
The steps
Steps
Not run on a board yet. Expect to adjust.
Wire it on the breadboardBENCH
With the USB cable unplugged, wire the sensor and the buzzer as in the pin table. Put the sensor where you can wave a hand in front of it.
Printable wiring sheet
Print the wiring: the build from above, each wire numbered at both ends with a legend. Opens on its own; print from there. You should see: Four wires to the sensor and two to the buzzer. Nothing is lit.
Build and flash the programTERMINAL
Build and flash the program. Plug the board into your computer with the USB cable first.
cd portability/hobby/parking-sensor && ./build.sh --board mspm0g3519 --flashYou should see: The build finishes and the flash reports done.
Move your hand toward itBENCH
Hold your hand about 30 cm in front of the sensor, then move it slowly toward the sensor.
You should see: The buzzer beeps slowly at first and faster as your hand gets closer, and the serial port (115200 baud) prints a line like
dist=34 cmten times a second. Beyond 100 cm it stays silent.Check it against a rulerBENCH
Hold a ruler beside the sensor and hold a flat object at 10, 30 and 100 cm.
You should see: The distance the program prints at each mark matches the ruler.
Read the serial output
Open the board's USB serial port in any terminal program at 115200 baud. The lines the program prints appear there.
The key lines
A 12 microsecond trigger pulse, then the echo pulse is timed and divided by 58 to give centimeters. the source
static int measure_cm(void)
{
hb_out(HB_TRIG, 1);
hb_delay_us(12);
hb_out(HB_TRIG, 0);
uint32_t t0 = hb_us();
while (!hb_in(HB_ECHO)) {
if ((uint32_t) (hb_us() - t0) > ECHO_WAIT_US) {
return -1;
}
}
uint32_t rise = hb_us();
while (hb_in(HB_ECHO)) {
if ((uint32_t) (hb_us() - rise) > ECHO_WAIT_US) {
return -1;
}
}
return (int) ((hb_us() - rise) / 58u);
}Not run on a board yet. Expect to adjust.
Wire it on the breadboardBENCH
With the USB cable unplugged, wire the sensor and the buzzer as in the pin table. Put the sensor where you can wave a hand in front of it.
Printable wiring sheet
Print the wiring: the build from above, each wire numbered at both ends with a legend. Opens on its own; print from there. You should see: Four wires to the sensor and two to the buzzer. Nothing is lit.
Build and flash the programTERMINAL
Build and flash the program. Plug the board into your computer with the USB cable first.
cd portability/hobby/parking-sensor && ./build.sh --board mspm0g3507 --flashYou should see: The build finishes and the flash reports done.
Move your hand toward itBENCH
Hold your hand about 30 cm in front of the sensor, then move it slowly toward the sensor.
You should see: The buzzer beeps slowly at first and faster as your hand gets closer, and the serial port (115200 baud) prints a line like
dist=34 cmten times a second. Beyond 100 cm it stays silent.Check it against a rulerBENCH
Hold a ruler beside the sensor and hold a flat object at 10, 30 and 100 cm.
You should see: The distance the program prints at each mark matches the ruler.
Read the serial output
Open the board's USB serial port in any terminal program at 115200 baud. The lines the program prints appear there.
The key lines
A 12 microsecond trigger pulse, then the echo pulse is timed and divided by 58 to give centimeters. the source
static int measure_cm(void)
{
hb_out(HB_TRIG, 1);
hb_delay_us(12);
hb_out(HB_TRIG, 0);
uint32_t t0 = hb_us();
while (!hb_in(HB_ECHO)) {
if ((uint32_t) (hb_us() - t0) > ECHO_WAIT_US) {
return -1;
}
}
uint32_t rise = hb_us();
while (hb_in(HB_ECHO)) {
if ((uint32_t) (hb_us() - rise) > ECHO_WAIT_US) {
return -1;
}
}
return (int) ((hb_us() - rise) / 58u);
}Make it yours
By hand
Open portability/hobby/parking-sensor/app.c in a text editor. Change the distance where the beeping stops, the gap between beeps, or the pitch. Run the command from step 2 after each change.
You should see: The change shows within seconds of the flash.
By hand
Open portability/hobby/parking-sensor/app.c in a text editor. Change the distance where the beeping stops, the gap between beeps, or the pitch. Run the command from step 2 after each change.
You should see: The change shows within seconds of the flash.
What to build next
If something goes wrong
| The sensor has a header with SCL and SDA printed beside Trig and Echo | Use the Trig and Echo pins: the other pair is for its serial modes. |
| The build stops and names a missing tool | Install that tool from the page it names and run the command again. |
| The flash cannot find the board | Try another USB cable: a charge-only cable looks the same. |
The serial port prints dist=none | Check the echo wire first: a loose echo wire reads as no object in range. |
| The readings are far too large | Soft or angled surfaces reflect little sound; use a flat, hard object. |
More troubleshooting
| The old behavior is still there | The flash did not finish: run the command from the build step again and wait for done. |
Every fix for this board: the FAQ.
| The sensor has a header with SCL and SDA printed beside Trig and Echo | Use the Trig and Echo pins: the other pair is for its serial modes. |
| The build stops and names a missing tool | Install that tool from the page it names and run the command again. |
| The flash cannot find the board | Try another USB cable: a charge-only cable looks the same. |
The serial port prints dist=none | Check the echo wire first: a loose echo wire reads as no object in range. |
| The readings are far too large | Soft or angled surfaces reflect little sound; use a flat, hard object. |
More troubleshooting
| The old behavior is still there | The flash did not finish: run the command from the build step again and wait for done. |
Every fix for this board: the FAQ.
Get the code
Ran here, with steps.
Start it
Paste this in a terminal. It hands off to an AI assistant with this board's notes.
git clone --depth 1 --filter=blob:none https://github.com/Fox-Red-Labs/fox-red-labs.git && cd fox-red-labs
./start.sh mspm0g3519 hobby-parking-sensor --assistant claudegit clone --depth 1 --filter=blob:none https://github.com/Fox-Red-Labs/fox-red-labs.git && cd fox-red-labs
py start.py mspm0g3519 hobby-parking-sensor --assistant claudeNot Claude Code? Copy this prompt instead.
Only the code for this board
git clone --depth 1 --filter=blob:none --sparse https://github.com/Fox-Red-Labs/fox-red-labs.git
cd fox-red-labs
git sparse-checkout set mspm0g3519Ran here, with steps.
Start it
Paste this in a terminal. It hands off to an AI assistant with this board's notes.
git clone --depth 1 --filter=blob:none https://github.com/Fox-Red-Labs/fox-red-labs.git && cd fox-red-labs
./start.sh mspm0g3507 hobby-parking-sensor --assistant claudegit clone --depth 1 --filter=blob:none https://github.com/Fox-Red-Labs/fox-red-labs.git && cd fox-red-labs
py start.py mspm0g3507 hobby-parking-sensor --assistant claudeNot Claude Code? Copy this prompt instead.
Only the code for this board
git clone --depth 1 --filter=blob:none --sparse https://github.com/Fox-Red-Labs/fox-red-labs.git
cd fox-red-labs
git sparse-checkout set mspm0g3507Or take the whole repository
git clone https://github.com/Fox-Red-Labs/fox-red-labs.gitReports from others, and the report forms
Clone the repository and open the board's folder below. AGENTS.md is a plain text file of notes for AI coding assistants, and llms.txt at the root indexes the site for one.
git clone https://github.com/Fox-Red-Labs/fox-red-labs.git
- LP-MSPM0G3507: folder
mspm0g3507/.- README: the board's lab notebook (what was run, in order)
- Notes for an AI coding assistant working in this repository: notes for an AI assistant; copy it into your own project if you use one
- FAQ: errors and fixes
The other 4 board folders
- LP-MSPM0L1306: folder
mspm0l1306/.- README: the board's lab notebook (what was run, in order)
- Notes for an AI coding assistant working in this repository: notes for an AI assistant; copy it into your own project if you use one
- FAQ: errors and fixes
- LP-EM-CC2340R5: folder
cc2340r5/.- README: the board's lab notebook (what was run, in order)
- Notes for an AI coding assistant working in this repository: notes for an AI assistant; copy it into your own project if you use one
- FAQ: errors and fixes
- LAUNCHXL-F2800137: folder
c2000-launchpad/.- README: the board's lab notebook (what was run, in order)
- Notes for an AI coding assistant working in this repository: notes for an AI assistant; copy it into your own project if you use one
- FAQ: errors and fixes
- LP-MSPM0G3519: folder
mspm0g3519/.- README: the board's lab notebook (what was run, in order)
- Notes for an AI coding assistant working in this repository: notes for an AI assistant; copy it into your own project if you use one
- FAQ: errors and fixes
- LP-MSPM0L1306: folder
Code is BSD-3-Clause, writing is CC BY 4.0; third-party folders keep their own licenses.
Built it? Tell us
Built this, or got stuck? Report it on GitHub with a few short answers. Your report shows here in your words, marked as yours. A failure that repeats on the bench gets its fix here.
Evidence and limitsNot run. Results, sources, timing and limits.
How it works
The program sends a short pulse on the trigger pin. The sensor sends out a burst of ultrasound and raises the echo pin until the sound comes back. The time the echo pin stays high is the round trip, so the distance is that time halved and multiplied by the speed of sound.
A counter that runs freely at the CPU clock stamps the rising and falling edges of the echo pin, so the program does not need a hardware capture. The distance sets the beep: 40 ms beeps, with a gap of 60 ms plus 5 ms for each centimeter, and silence beyond 100 cm.
RCWL-1601 parking sensor
Expected result: The beep rate rises as the object gets closer. Distance error at three ranges, the measuring rate and image size: measured at the first run.
What this shows
- Distance is the time an echo takes to return, halved and multiplied by the speed of sound.
- A timer capture times the echo without the program waiting on it.
What this does not establish, and limits
What this does not establish
- That the program runs: nobody has run this build yet.
- How accurate it is: the error at three ranges is measured at the first run.
Limits to keep in mind
- The sensor reads a cone, not a line, and soft surfaces return little echo.
- The kit's HC-SR04 is a 5 V part and is not used here.
Sources
Versions, sizes and timing
| Size on the LP-MSPM0G3507 | 3.1 kB flash of 128 kB, 524 B RAM of 32 kB (the linker reserves 512 B of the RAM for the stack) | README notes |
|---|---|---|
| Size on the LP-MSPM0G3519 | 3.1 kB flash of 512 kB, 268 B RAM of 128 kB | README notes |
| Size on the LP-MSPM0L1306 | 3.1 kB flash of 64 kB, 268 B RAM of 4 kB | README notes |
| Build | MSPM0 SDK 2.11.00.07, TI Arm Clang 5.1.1.LTS at -Os, SysConfig 1.28.0, built 2026-11-08 | README notes |
Other boards
- MSPM0G3507, CC2340R5, F2800137
- MSPM0L1306same portable layer, not yet run
What the status words mean
Works ran here and did what it shouldCould work some of it ran; real porting effort is left; hover for whatNot for this chip the chip or its vendor software cannot; hover for why
RCWL-1601 parking sensor
Expected result: The beep rate rises as the object gets closer. Distance error at three ranges, the measuring rate and image size: measured at the first run.
What this shows
- Distance is the time an echo takes to return, halved and multiplied by the speed of sound.
- A timer capture times the echo without the program waiting on it.
What this does not establish, and limits
What this does not establish
- That the program runs: nobody has run this build yet.
- How accurate it is: the error at three ranges is measured at the first run.
Limits to keep in mind
- The sensor reads a cone, not a line, and soft surfaces return little echo.
- The kit's HC-SR04 is a 5 V part and is not used here.
Sources
Versions, sizes and timing
| Size on the LP-MSPM0G3507 | 3.1 kB flash of 128 kB, 524 B RAM of 32 kB (the linker reserves 512 B of the RAM for the stack) | README notes |
|---|---|---|
| Size on the LP-MSPM0G3519 | 3.1 kB flash of 512 kB, 268 B RAM of 128 kB | README notes |
| Size on the LP-MSPM0L1306 | 3.1 kB flash of 64 kB, 268 B RAM of 4 kB | README notes |
| Build | MSPM0 SDK 2.11.00.07, TI Arm Clang 5.1.1.LTS at -Os, SysConfig 1.28.0, built 2026-11-08 | README notes |
Other boards
What the status words mean
Works ran here and did what it shouldCould work some of it ran; real porting effort is left; hover for whatNot for this chip the chip or its vendor software cannot; hover for why
Result grid
Works ran here and did what it shouldShould work it builds; only naming, packaging or build glue is in the way; hover for whichCould work some of it ran; real porting effort is left; hover for whatNot for this chip the chip or its vendor software cannot; hover for why
