Skip to content

STEM racing – 1.2 The Trigger Switch

Build Your Own USB-C Launch Pendant

This guide provides step-by-step instructions for building a custom, ultra-low latency USB-C trigger for the Dyson-Mills F1 Launch Simulator. This is an excellent STEM project that introduces students to basic soldering, microcontrollers, and HID (Human Interface Device) programming.

1. Parts & Suppliers (France / Luxembourg)

You can source all necessary components from dedicated maker and arcade shops in France.

Component Description Recommended Suppliers
Microcontroller Seeed Studio XIAO RP2040 or XIAO SAMD21. Tiny, inexpensive, and features native USB-C. Gotronic.fr, Kubii.fr
Push Button 16mm or 24mm Arcade Button (e.g., Sanwa) or a standard momentary push button. SmallCab.net, Gotronic.fr
Enclosure A 3D-printed handle, a small plastic project box (boîtier), or a cut piece of PVC pipe. School 3D Printer or Hardware Store
Wiring & Cable 2x short jumper wires and 1x USB-C to USB-C (or USB-A) data cable. Any electronics retailer

2. Hardware Assembly

  1. Prepare the Enclosure: Drill a hole in the top of your casing perfectly sized for your push button (usually 16mm or 24mm). Drill a smaller hole at the bottom for the USB-C cable to exit.
  2. Mount the Button: Insert the arcade button into the top hole and secure it with the provided plastic nut.
  3. Wiring the Circuit:
    • Strip the ends of your two jumper wires.
    • Solder one wire from one terminal of the button to the GND (Ground) pin on the XIAO microcontroller.
    • Solder the second wire from the other terminal of the button to Pin D0 on the XIAO microcontroller.
  4. Final Assembly: Plug the USB-C cable into the microcontroller. Route the cable out the bottom of the enclosure and seal the unit.
Pro Tip: Ensure you are using a USB-C data cable, not just a charging cable. The computer needs data lines to recognize the device as a keyboard.

3. Programming the Microcontroller

We need to tell the microcontroller to act like a standard computer keyboard and press the “Spacebar” whenever the button is pushed.

  1. Download and install the free Arduino IDE.
  2. In the Arduino IDE, go to Tools > Board > Boards Manager and install the “Seeed SAMD Boards” or “Raspberry Pi Pico/RP2040” package, depending on which XIAO you bought.
  3. Plug your assembled pendant into your computer via USB. Select its COM port in Tools > Port.
  4. Copy and paste the following code into the Arduino editor:
#include <Keyboard.h>

const int buttonPin = 0; // Connect button to Pin D0
int buttonState = HIGH;      
int previousButtonState = HIGH; 

void setup() {
  // Set the pin as input with an internal pull-up resistor.
  // This means the pin reads HIGH when unpressed, and LOW when pressed to Ground.
  pinMode(buttonPin, INPUT_PULLUP);
  
  // Initialize the keyboard emulation
  Keyboard.begin();
}

void loop() {
  buttonState = digitalRead(buttonPin);
  
  // Check if the button was just pressed (transition from HIGH to LOW)
  if (buttonState == LOW && previousButtonState == HIGH) {
    Keyboard.press(' '); // Send the Spacebar keystroke
    delay(10);           // Hardware debounce delay
  }
  
  // Check if the button was just released (transition from LOW to HIGH)
  if (buttonState == HIGH && previousButtonState == LOW) {
    Keyboard.releaseAll(); // Release the key
    delay(10);
  }
  
  previousButtonState = buttonState;
}
  1. Click the Upload button (the right arrow icon). Once it says “Done uploading”, your pendant is ready!

4. Testing on the Simulator

Open the Dyson-Mills Racing Simulator. Do not click the screen—simply hold your new pendant and press the button. The game will immediately register the “Spacebar” input and stop the timer, giving you physical hardware speeds in a web environment.

Comments are closed, but trackbacks and pingbacks are open.