GitHub Digital Lab

Fox Red Labs / Builds / Tools and languages

Button, knob and dimmer on a breadboard

The board's S2 button toggles an LED, then a knob sets how bright it is.

EasyWiring neededOne sitting

You learn: Digital input with a pull-up, analog input, and PWM brightness.

Drag the bar to a step and let go to stop there; Play continues from it. Drag the picture to turn, scroll to zoom. Pin view looks straight down at the step. Tap a step, a part or a pin.
All 15 wiring steps
  1. 1Put the breadboard beside the LaunchPadSet the half-size breadboard on the right with its numbers running up the page. Letters a to j run across it and numbers 1 to 30 run along it, so every hole has a name like j7. The LaunchPad stays unplugged until the last step.The breadboard sits to the right of the LaunchPad. The LaunchPad has no USB cable in it yet.
  2. 2Ground first: LaunchPad GND to the blue railPush one end of a black jumper wire into the LaunchPad socket J2 pin 20 (GND) and the other end into the top blue rail. Wiring ground first means a part you plug in later is never live without a return path. A rail is a long strip of holes joined end to end, so any hole on it is ground.Both ends of the black wire show their tag: J2 pin 20 (GND) and the top blue rail.
  3. 33.3 V to the red railA red wire from J1 pin 1 (3V3) to the top red rail. Only the knob uses it in this build.
  4. 4Resistor in firstPut the 330 ohm resistor (orange, orange, brown) in holes h3 and h6. Without a resistor in series the LED would draw too much current from the pin. A series resistor is one wired in line with a part to limit the current through it.The resistor lies flat across three holes in row h, with its legs in h3 and h6.
  5. 5The LED, long leg toward the resistorPush the LED legs into f6 and f7. The long leg (plus, anode) goes in f6, the same column as the resistor's right leg. The short leg with the flat edge goes in f7. Backwards, it just stays dark.The long leg is in column 6, in line with the resistor's far leg. Nothing else shares column 7 yet.
  6. 6LED minus to groundA black wire from j7 (the short leg's column) to the ground rail closes the loop on the minus side.
  7. 7Signal wire from J3 pin 28A yellow wire from j3, the resistor's left column, to J3 pin 28 (PB27). The chip drives this pin to light the LED. A GPIO (general-purpose input or output) pin is one the program sets high or low.Yellow wire from breadboard j3 to J3 pin 28 (PB27).
  8. 8The button is already on the boardThe button is S2, the one on the LaunchPad's right edge, so there is nothing to wire for it. The program turns on its pull-up: a resistor inside the chip that holds the pin at 3.3 V until the button pulls it to ground, so the pin never floats.S2 is the button at the right edge of the LaunchPad, beside the headers.
  9. 9Run part 1Plug in USB and run the button program. Each press of S2 toggles the LED.LED changes state each time you press S2.
  10. 10The knob in the breadboardPress the 10 k knob into g23, g24 and g25. It has three pins: the outer two go across the supply and the middle one, the wiper, gives a voltage that follows the turn.The knob stands upright with its three pins side by side in row g.
  11. 11Knob to 3.3 V and groundA red wire from j23 to the red rail and a black wire from j25 to the blue rail put 3.3 V across the knob. 3.3 V, not 5 V: the chip's pins cannot take more than that.Red wire at the knob's left pin, black wire at its right pin.
  12. 12Wiper to J1 pin 2An orange wire from j24 (middle pin) to J1 pin 2 (PA14). That pin is an analog input: an ADC (analog-to-digital converter) turns the voltage on it into a number, 0 at 0 V up to 4095 at 3.3 V.Orange wire from j24 to J1 pin 2 (PA14). Turning the knob changes the number the program prints.
  13. 13Run part 2Run the knob program and watch the number in the serial terminal while you turn the knob from one end to the other.The printed number runs near 0 at one end and near 4095 at the other.
  14. 14Same LED, now dimmedNo new wire. The LED is on J3 pin 28 (PB27), a pin a timer can drive. PWM (pulse-width modulation) switches the pin on and off thousands of times a second; the longer it stays on in each cycle, the brighter the LED looks.
  15. 15Knob sets the brightnessRun the dim program. It reads the knob (part 2) and uses the number as the PWM duty (the share of each cycle the pin is on). Turn the knob and the LED goes from off to full.Knob to the left: LED off. Knob to the right: LED full. In between it dims smoothly.
Every wire and signal, far end to board end
Every wire, far end to board end
WireFromToStep
Ground railGround rail (blue, hole 2)J2 pin 20 (GND)2
3.3 V rail3V3 rail (red, hole 2)J1 pin 1 (3V3)3
LED signalResistor, breadboard j3J3 pin 28 (PB27)7
LED minus to groundLED minus, breadboard j7Ground rail6
Knob to 3.3 VKnob outer pin, breadboard j233V3 rail11
Knob to groundKnob outer pin, breadboard j25Ground rail11
Knob wiper signalKnob middle pin, breadboard j24J1 pin 2 (PA14)12
Every signal to the LaunchPad
SignalPart pinLaunchPad pinWhat the program does with it
BTN_AButton S2 (on the board)J4 pin 40 (PB3)Digital input, internal pull-up
LEDLED through 330 ohm, hole j3J3 pin 28 (PB27)Timer PWM output
POT1Knob wiper, hole j24J1 pin 2 (PA14)ADC input

Wire an LED and a knob; the button is on the board

What you need

Should work: same portable layer, not yet run by a person
LP-MSPM0G3519
BreadboardHalf-size breadboard
330 ohm resistorResistor
Red LEDLED
10 k knobPotentiometer (the knob)
Jumper wires x7the wires drawn in the build
Micro-USB cablecomes with the board; powers and programs it
Freenove Ultimate Starter Kit for Raspberry Pi Pico, board not includedhas all of the above
On 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

Button, knob and dimmer

Wiring. Knob wiper to J1 pin 2 (PA14), its ends to J1 pin 1 (3V3) and J2 pin 20 (GND). The LED is LED2 green on the board, J3 pin 28 (PB27); an outside LED through 330 Ω works there too. S2 is on the board, J4 pin 40 (PB3); optional: your own button on J2 pin 15 (PB8), other side to GND.

Tap a block or a step to follow one job.

ProcessorMemoryAnalogTimersSerial and pinsSystemMath and securityThe block in use, with its arrowsPinsFlash and SRAM in useStack

The steps

Steps

Not run on a board yet. Expect to adjust.

  1. Wire it on the breadboardBENCH

    With the USB cable unplugged, put the LED with its resistor and the knob on the breadboard and wire them as in the pin table. The button is S2 on the board, so it needs no wire.

    Printable wiring sheet
    The same build drawn from above: board, breadboard, parts and every wire numbered at both ends
    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: Two small circuits on the breadboard, each ending at the LaunchPad. Nothing is lit.

  2. Build and flash the programTERMINAL

    Build and flash the program. Plug the board into your computer with the USB cable first. The script is a bash script. Not run on Linux or Windows.

    cd portability/hobby/button-knob-dim && ./build.sh --board mspm0g3519 --flash

    You should see: The build finishes and the flash reports done.

  3. Press S2BENCH

    Press S2, the button on the board.

    You should see: The LED toggles on each press.

  4. Turn the knobBENCH

    Turn the knob slowly from one end to the other.

    You should see: The LED gets brighter as you turn one way and dimmer the other way. The serial port (115200 baud) prints a line like adc=914 led=on duty=22 twice a second.

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

Each press of S2 flips led_on after a 20 ms debounce; the knob's reading becomes the PWM high time. the source

uint32_t now = hb_ms(); int btn = hb_in(HB_BTN_A) && hb_in(HB_BTN_B); /* low when either button is held */ if (btn != btn_prev && (uint32_t) (now - t_edge) >= DEBOUNCE_MS) { t_edge = now; btn_prev = btn; if (!btn) { /* pressed: the button pulls the pin to ground */ led_on = !led_on; } } uint32_t high_us = led_on ? ((uint32_t) adc * PWM_PERIOD_US) / 4095u : 0u; duty_pct = high_us * 100u / PWM_PERIOD_US; if (high_us != last_high) { last_high = high_us; hb_pwm(HB_LED, PWM_PERIOD_US, high_us);

Make it yours

By hand

Open portability/hobby/button-knob-dim/app.c in a text editor. Change PWM_PERIOD_US, stop the knob at half brightness, or make S2 hold the LED on for two seconds. Run the command from step 2 after each change.

You should see: The change shows within seconds of the flash.

What to build next

Blink an LEDThe board's LED blinks, then blinks the pattern you set
Build and flash from the terminal in one commandTI's examples build and flash from one terminal command, no window
Print a message from the board on your computerText from the chip appears in a terminal on your computer, and what you type goes back

Every build

If something goes wrong

The LED never lights laterTurn it around: the long leg goes to the resistor side.
The build stops and names a missing toolInstall that tool from the page it names and run the command again.
The flash cannot find the boardTry another USB cable: a charge-only cable looks the same.
Nothing happensCheck that the LED's resistor leg is on J3 pin 28 and its other leg on ground. The pins are listed in portability/hobby/button-knob-dim/PINS.md.
It only jumps between off and fullThe middle pin is on a digital pin or the outer pins are swapped; check the pin table.
More troubleshooting
The old behavior is still thereThe 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.

./start.sh mspm0g3519 hobby-button-knob-dim --assistant claudegit clone --depth 1 --filter=blob:none https://github.com/Fox-Red-Labs/fox-red-labs.git && cd fox-red-labs ./start.sh mspm0g3519 hobby-button-knob-dim --assistant claude
Not Claude Code? Copy this prompt instead.
Clone https://github.com/Fox-Red-Labs/fox-red-labs and read mspm0g3519/AGENTS.md first. Then run Button, knob and dimmer on my LP-MSPM0G3519. Tell me when to plug in the board and what you saw at each step.
Only the code for this board
git sparse-checkout set mspm0g3519git 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 mspm0g3519
Or take the whole repository
git clone https://github.com/Fox-Red-Labs/fox-red-labs.git
Reports 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

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

S2 on the board pulls its pin to ground when you press it, and the chip's internal pull-up holds the pin high otherwise, so the program reads a low level for a press. It waits 20 ms after an edge before it believes the next one. The knob is a voltage divider: its middle pin sits between 0 V and 3.3 V, and the analog-to-digital converter turns that voltage into a number from 0 to 4095.

PWM switches the LED on and off 1,000 times a second. The share of each cycle that the LED is on sets how bright it looks, so the program turns the knob's number into that share. The program also prints the number, the LED state and the duty on the serial port twice a second.

Button, knob and dimmer

Expected result: S2 toggles the LED and the knob sets its brightness from off to full. The PWM rate is 1 kHz by design; the measured brightness range and build time: measured at the first run.

What this shows

  • A knob, an LED and one resistor connect to a LaunchPad with five wires; the button is already on the board.
  • Digital input, analog input and PWM output are three separate peripherals; this build uses each once.
What this does not establish, and limits

What this does not establish

  • That the program runs: nobody has run this build yet.
  • Any timing or brightness figure: those are measured at the first run.

Limits to keep in mind

  • The LED is driven straight from a pin through 220 Ohm.
  • The pins are listed in the build folder's PINS.md, one table per board.

Sources

Versions, sizes and timing

Size on the LP-MSPM0G35073.2 kB flash of 128 kB, 712 B RAM of 32 kB (the linker reserves 512 B of the RAM for the stack)README notes
Size on the LP-MSPM0G35193.2 kB flash of 512 kB, 456 B RAM of 128 kBREADME notes
Size on the LP-MSPM0L13063.1 kB flash of 64 kB, 268 B RAM of 4 kBREADME notes
BuildMSPM0 SDK 2.11.00.07, TI Arm Clang 5.1.1.LTS at -Os, SysConfig 1.28.0, built 2026-11-08README 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

Button, knob and dimmer

Expected result: S2 toggles the LED and the knob sets its brightness from off to full. The PWM rate is 1 kHz by design; the measured brightness range and build time: measured at the first run.

What this shows

  • A knob, an LED and one resistor connect to a LaunchPad with five wires; the button is already on the board.
  • Digital input, analog input and PWM output are three separate peripherals; this build uses each once.
What this does not establish, and limits

What this does not establish

  • That the program runs: nobody has run this build yet.
  • Any timing or brightness figure: those are measured at the first run.

Limits to keep in mind

  • The LED is driven straight from a pin through 220 Ohm.
  • The pins are listed in the build folder's PINS.md, one table per board.

Sources

Versions, sizes and timing

Size on the LP-MSPM0G35073.2 kB flash of 128 kB, 712 B RAM of 32 kB (the linker reserves 512 B of the RAM for the stack)README notes
Size on the LP-MSPM0G35193.2 kB flash of 512 kB, 456 B RAM of 128 kBREADME notes
Size on the LP-MSPM0L13063.1 kB flash of 64 kB, 268 B RAM of 4 kBREADME notes
BuildMSPM0 SDK 2.11.00.07, TI Arm Clang 5.1.1.LTS at -Os, SysConfig 1.28.0, built 2026-11-08README 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

Project
LP-MSPM0G3507MSPM0G3507 chip
LP-MSPM0L1306MSPM0L1306 chip
LP-EM-CC2340R5CC2340R52 chip
LAUNCHXL-F2800137TMS320F2800137 chip
Button, knob and dimmer
LP-MSPM0G3507
LP-MSPM0L1306
LP-EM-CC2340R5
LAUNCHXL-F2800137

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