The DigiRule

Digirules are available again from my Tindie store:

Here’s a youtube video of the improved version:

And now back to the original post…

This project is completely open source. You can download all files including PCB layout, source code and BOM in the link at the bottom of this page.

UPDATE: 30 December 2015 – Jaap has made a really cool DigiRule Java Simulator which you can check out in the link below. Try the DigiRule without having a DigiRule!

DigiRule Java Simulator

I’ve seen a number of PCB rulers out there for example this one from Adafruit:

However I wanted to make one that was a little more interesting and of course, should have some LED’s built in. (LED’s seem to make electronic projects more interesting…)

So I made the DigiRule! – The DigiRule is a 15cm (6″) ruler with which is marked in binary digits rather than decimal. It has a number of built in digital functions including:

  • Logic Gates
    • NOT Gate (Inverter)
    • OR Gate
    • AND Gate
    • XOR Gate
    • NOR Gate
    • NAND Gate
    • XNOR Gate
  • Flip Flops
    • SR Flip Flop
    • JK Flip Flop
    • Toggle Flip Flop
    • Data Flip Flop
  • Four bit binary up/down counter

It is powered by a single 3V CR2032 button battery and the brains of the unit is a PIC 18F45K20 microcontroller (which is a greatly over powered device for such a simple task – but they are cheap!)  The functions listed above are controlled by nine surface mount push buttons and has twenty three surface mount LED’s to show the status of the inputs and outputs.


The rear of the ruler contains logic gate and flip flop truth tables, a binary conversion chart, a few select SMD component footprints and some drill hole sizes.



Check out the youtube video for a demonstration:

Here is the ICSP (In Circuit Serial Programming) port connector pinout.

Screen Shot 2015-12-16 at 10.16.17 am

Click below to download the DigiRule archive – note this contains all software fixes for the button bounce issue and the SR flip flop issue. It also contains a simple user manual to help with using the DigiRule. (Note, there seems to be an issue with Diptrace not importing the silkscreen images so I have included these in the latest download for if you want to modify it at all within Diptrace)


Additional (free) software to go with the above download include:

Diptrace – The PCB editor that I used to design the DigiRule

Swordfish Basic – The IDE that I used to code the DigiRule

PICKIT2 Software – The software that I use to transfer the .hex file to the DigiRule’s microcontroller

And finally, a PICKIT2 (or similar) USB programmer to actually copy the .hex file to the microcontroller (this is used in conjunction with the PICKIT2 Software). You can buy a genuine PICKIT2 or 3 from or you can buy a clone for cheaper. Since microchip has released the PICKIT2 hardware and firmware as open source, there is no problem with buying a clone. I recommend this one: