Skip to content

Tutorial: How to Develop for the Trigger Master

Image used with permission from imakeprojects.comThe Trigger Master is not just for giving your AEG 3-round bursts! It does a lot more than that under the hood, and it’s capable of even more. It’s a fully computer controlled electronic fire control system for your AEG which has capabilities miles beyond the dumb switch your gun comes with.

This tutorial will tell you all you need to know to start modifying the programming of these great units to add or tweak your own features!

Note: The newest versions of the Trigger Master (Mark III) all use surface-mounted ATTINY85 chips. They cannot be popped in and out of their sockets like for previous models. You will need a special socket to program them, and you will need to desolder and replace the chip on the Trigger Master to replace it. Other than the physical shape of that chip being different, everything else referred to on this page is the same.

The computer brains of the Trigger Master (and’s SW-COMPUTER series – the two are 100% compatible with each other) is a small microcontroller called the ATTINY85. It is possible to modify the program for the Trigger Master, or even write an entirely new one to add your own features! Anywhere I talk about the Trigger Master, it also applies to the SW-COMPUTER (unless I specifically say otherwise).

This tutorial will show you how to do exactly that. As long as you’re a passable C programmer and have a working knowledge of electronics (experience in micro design is a big plus), you’ll be on your way in no time.

What you will need

To modify the program for the Trigger Master or SW-COMPUTER, you will need the following:

  1. A Trigger Master from our Store (or SW-COMPUTER from
  2. An ATTINY85 AVR Microcontroller (this will be the chip you work on) The Digi-Key part number is ATTINY85-20PU-ND.
  3. A setup for developing for and programming the ATTINY85 chip (see below for details)

How this will work

Here is how the process of developing and running your own programs on the Trigger Master (or SW-COMPUTER) looks from 10,000 feet up:

  1. Set yourself up with the necessary hardware and software to develop programs for the ATTINY85 chip.
  2. Obtain the latest source code for the Trigger Master from here, or the SW-COMPUTER from here. (The Trigger Master and SW-COMPUTER programs can be expected to differ slightly from one another, but they work basically the same.)
  3. Modify the source code as you desire (add features, tweak settings, etc).
  4. Compile the code into a .hex file.
  5. Program that .hex file into your ATTINY85 chip.
  6. Replace the ATTINY85 in your Trigger Master or SW-COMPUTER with your new one.
  7. Power up your gun and test out your changes!
  8. Return to step 3 as necessary (you can expect to have to move the chip carefully between your programmer and your Trigger Master a lot when developing).

How To Do All That

The Development Environment

Fortunately, most of the work is done for us in the form of this link: A Quickstart Tutorial for AVR Microcontrollers.

So before you do anything else, go to that link and follow that tutorial, but substitute our ATTINY85 chip for the ATTINY45.

To reiterate: That tutorial is exactly what you need to know in order to get a development environment in place. Remember: Just use the ATTINY85 instead of the ATTINY45 when following that tutorial. Everything else is the same!

By the end of that tutorial you will have a development environment working – you’ll have the software and hardware necessary to make programs and put them into the ATTINY85.

Once you are comfortable with that, continue with the next section.

Loading Up The Trigger Master (or SW-COMPUTER) Source Code

Start a new project in AVR Studio like the tutorial taught you. Call your project something like “MyFireControl”. Remember to select ATTINY85 as the target device.

Now take the .c source code you obtained for either the Trigger Master or SW-COMPUTER and copy & paste it into the blank window for MyFireControl.c. Make no changes to it just yet.

Make sure it works: Build (compile) the code as-is, like you learned in the Tutorial with Build->Build (or the F7 shortcut). The code should compile cleanly with no Warnings or errors.

Make Your Desired Changes to the Code

As a simple first test, I would suggest the following simple change to the source code.

After firing, the Trigger Master (and SW-COMPUTER) vibrate the motor once to signal a “low battery” condition. To the user, it feels like a cellphone set to “vibrate”.

We’re going to make a simple change that will cause the motor to vibrate after every time the user fires. No real purpose will be served by this – it’s just to demonstrate making a simple change.

First, find this section in the source code – it’s the part that stops any firing (CeaseFire).


 /*	The motor ON and OFF functions have a 1mS anti cross conduction safety delay built in */
 /*	Turn motor to off */

/*	Turn break to on */

/*	Leave the break on for some time in mS */

/*	Turn break to off */

 /*  If in semi mode, set burst time */
 if (TriggerHold ==0) {SetBurstTime(ShotCounter);}

/*  Check unit temperature */
 if (GetVoltage(Temperature,2) > 283 + ((TemperatureLimit * 13) / 10)) {EventLog(3); ErrorCode = 18;}

ModeCounter = 0; DeadTimeCounter = 0;
/*  If an error occured report it */
 if (ErrorCode == 0) {goto MainLoop;}
 	/*	16 - Low battery - Vibrate motor once after firing
 		17 - High motor peak current - Vibrate motor twice
 		18 - Overheating - Vibrate motor three times


 	if (ErrorCode == 16) {Vibrate();Timer(500);}
 	if (ErrorCode == 17) {Vibrate(); Timer(500); Vibrate();Timer(500);}
 	if (ErrorCode == 18) {Vibrate(); Timer(500); Vibrate(); Timer(500); Vibrate();Timer(500);}

ErrorCode = 0;

goto MainLoop;

Now in this part, add the code in red:

        ErrorCode = 16;     // Force an error code of "low battery"
/*  If an error occured report it */
 if (ErrorCode == 0) {goto MainLoop;}
 	/*	16 - Low battery - Vibrate motor once after firing
 		17 - High motor peak current - Vibrate motor twice
 		18 - Overheating - Vibrate motor three times


 	if (ErrorCode == 16) {Vibrate();Timer(500);}
 	if (ErrorCode == 17) {Vibrate(); Timer(500); Vibrate();Timer(500);}
 	if (ErrorCode == 18) {Vibrate(); Timer(500); Vibrate(); Timer(500); Vibrate();Timer(500);}

That change will make the chip act as though there was a low battery condition every time the user stop firing, thus causing the motor to vibrate no matter what!

Next, we’ll compile this code, and test it out in your gun!

Program your new chip and test it

Use the programmer to program (burn) the .hex file you compiled (e.g. MyFireControl.hex) into your ATTINY85 chip.

Replace the chip on your Trigger Master (or SW-COMPUTER) with your newly-programmed chip. To do this, make sure power is disconnected, then carefully cut away the heatshrink above the chip to make a window a little larger than the chip itself. Make sure not to nick any wires or parts! Then carefully lever out the chip from the bottom with a small screwdriver and remove it from the socket. Careful! There are small parts on the board underneath that chip!

Then, simply plug your new chip in (no need to press it in all the way if it’s just a quick test – just push it in enough so that it’s held snug). Then plug in the battery and test out your chip!

Notes And Gotchas

Now that you know the bare minimum to change the guts of the Trigger Master’s brain, keep the following in mind as you go on to fiddle and tamper and build your master custom features:

  1. You can’t meaningfully run this code in the AVR Studio debugger, because it’s so dependent on the hardware of the Trigger Master or SW-COMPUTER. To test your changes you’re best off moving the chip back and forth between the AVRISP mkII programmer and your gun.
  2. The source code mentions that the brownout detection should be enabled and set to 4.3V. The part will mostly work without this, but it’s a good idea to remember to do it! You set this in the FUSES tab of the programmer interface.
  3. The source code also talks about special FUSES settings for the ATTINY85. Specifically, to be able to use pin 1 (AUX1) the reset disable fuse has to be set and the debug wire enable fuse has to be clear. Doing this will mean you will no longer be able to program the chip with your AVRISP MkII programmer. (That’s what “ISP interface will not be accessible” means). In short, turning on those options allows you to use AUX1 but no longer allows you to program the part with the ISP interface. If your customizations don’t use AUX1, you can leave those fuses alone and your chip will work.
  4. There is an active user and developer community for the SW-COMPUTER over at Airsoft Mechanics. Check it out!

Have fun!