Firmware for Airsoft Rounds Counter

Here is version 1 of the firmware for the Airsoft Rounds Counter project. The code uses avr-gcc but should be real easy to port if you use a different compiler.
This firmware is by no means the final version. Rather, it is the firmware for the breadboarded version (the schematic is here).

The ZIP archive contains three files:

  1. main.c
    Contains all the code. Please note that the code assumes that a LED is connected to PB4 which is not shown in the schematic. This is purely for debugging purposes and you can add the LED or not. The code doesn't care. And neither do I.
  2. Max7219.h
    Header file with definitions for the various Max7219 commands.
  3. Makefile
    Standard makefile. Do a 'make all' to compile, 'make fuse' to set fuses (they are set to internal 8 MHz RC oscillator with slow startup, no BOD, SPI enabled), 'make flash' to flash the ATTiny and 'make clean' to delete the binaries.

Download the ZIP archive here:

4 comments on "Firmware for Airsoft Rounds Counter"
Shawn (Takagari) says:

Wow this is awesome an dI can follow it along.
Once you nail down something you think work's I'll give it a build and do some playing. I guess now I need to build an AVR programmer.

Going SM how small can an avr etc get? I guess using a double sided board you could essentially make the unit, minus the segment, the size of the avr,

Keep in mind a 3 digit counter is required as some people use 130+ rnd magazines.

And something small. not sure how small a display can be used. but as you said size matters :)

I will be keeping an eye on this!

Thanks Again


Jens Willy Johannsen says:

Right now I'm using a four-digit display even though I could get by with a three-digit (I'm using 300 and 450 rnds hi-cap magazines) mainly because I had a bunch of those lying around.

I've made a PCB layout for SMD which is approx. 5 by 2 centimeters. I'll upload it one of the days. It could probably be made even smaller if I used both sides for components but I'm planning on mounting it inside a silencer along with the photo interrupter and there's room enough for a 5 x 2 cm board.

As for the programmer, I just bought an AVRISP mkII instead of trying to make one myself.

Jens W.

Randall Andrews says:

What did you use to program the ATtiny? As in programming cord?

Jens Willy Johannsen says:

@Randall: I use an AVRISP mkII programmer (USB connection to my Mac). To connect it to the chip I use a SOIC test clip (Digikey #923660-20-ND).

Leave a Reply