Pedal: Push to Talk device — Full build
Tags: csharp, showdev
Published: 2020-10-21 15:24:35

![Prototype for Pedal](https://miro.medium.com/max/1400/1*1N3qMAQbjont7QDV8ZOidA.jpeg)

There’s little time to play video games when you’re always working, but every once in a while, you can sneak an hour or two in. One of the games I’ve enjoyed recently is a WWII shooter called “Hell Let Loose.”

One of the qualities that attracts me to the game is the community and the extensive communication between players. It has a chain of command and people regularly communicate all the way from command down to squad; unlike Battlefield. Players can communicate directly with their squad, with their team, and with other players nearby their area.

![Hell Let Loose](https://miro.medium.com/max/1232/0*BZ9Lal9QLrGH8cDu)

There’s been plenty of times where I’d be eyeing up a shot down range while also wanting to tell squad mates about another thing happening; perhaps an incoming Tiger. I just didn’t have enough fingers to do it properly.

This is where building for utility comes into play.

Design for what you need, not for what you think you can do.
Ordinarily people wouldn’t go through so many steps to solve a problem, but this felt like the right way to do it. Try your best to do things the right way, not the easy way.

I started by creating a basic desktop application in Visual Studio using C# to test whether or not the SendKeys would work as expected. We used InputSimulator package to assist in simplifying the key presses.

The desktop application we created allows the user to set the triggers they need to initiate various actions. We’ll record key down events to add keys into a list, then wait for key ups to finish setting them.

![Soldering a button](https://miro.medium.com/max/1400/1*-2NODTT9iyhImU7wgp8mnA.jpeg)

I started with a basic USB mini microcontroller from Adafruit. The basic function sends an ON/OFF signal through the serial port. There’s not much left to do there, so now is the fun part where the digital calipers come out!

![1](https://miro.medium.com/max/834/1*_uF9uqTLQJnhlLJg5OTg0A.jpeg)
![2](https://miro.medium.com/max/4096/1*b8i1IL-E0xrbMdacfA4PSw.jpeg)
![3](https://miro.medium.com/max/798/1*grg5VCmwQHbf1sm1QBZDdw.png)

Digital calipers are an incredible tool for getting precise numbers. If you do it right, you only have to model and print once. It may sound weird, but my favorite part of this entire project was measuring out the specs for the model. It goes back to my love of drafting when I wanted to be an architect (2002); until I realized people don’t really use a T-Square and powder anymore.

After modeling the case based on my measurements, I ran it through my 3D printer. It feels really great to watch it build layer-by-layer and fit perfectly.

![Look at how perfectly that fits](https://miro.medium.com/max/1400/1*PoBjsHfDYqO5wDPrl-FlbA.jpeg)

It fit so snugly the controller didn’t even need to be glued, but I did anyway. A little spot of hot glue on the corners to keep it down. Some hot glue connecting the button to the lid. Then the top and bottom parts tightly slid together without any adhesive required.

One of the best parts of this build is how perfectly the USB port aligned with the print. It may not sound like a big deal, but it’s frustrating when all the pieces are laid out and the port is just a millimeter above or below the opening.

![Desktop application](https://miro.medium.com/max/1400/1*w9vmkrZuAdojTfoYBEqAcQ.jpeg)

At this point, I revised the desktop application design in Photoshop and started to integrate it into C#. It has a few extra options like how the keys will fire, toggling, etc. There’s a nice lighting effect on the buttons where an active light will highlight on the buttons themselves as well.

![Light off. Light on.](https://miro.medium.com/max/906/1*owt3Y5A01M81LKqxpjwRUw.png)

I added some code to connect the desktop application with the serial port of my device, listen to the IO, then broadcast key events. Right now, it connects directly on COM9 which is the benefit of it being an MVP.

```
public void SetupPort() {
    sp = new SerialPort("COM9");
    sp.BaudRate = 9600;
    sp.Parity = Parity.None;
    sp.StopBits = StopBits.One;
    sp.DataBits = 8;
    sp.Handshake = Handshake.None;
    sp.DataReceived += new SerialDataReceivedEventHandler(Handle_OnDataReceived);
    sp.ErrorReceived += new SerialErrorReceivedEventHandler(Handle_OnDataError);
sp.Open();
}
```

That’s pretty much it. Now I can use my foot to enable/disable push-to-talk when playing games freeing up my hands. No longer do I have an excuse for why I’m constantly getting shot in the game.

Here’s how it works:

{% youtube CrnOIrkZwxk %}