Arduino Project: The Making of a Digital Counter for a Coil Winding Machine

In the video we show how to make a coil winding counter out of an Arduino and some 7-segment displays. Below, we go in depth into the whys and hows of making it.

Why make a coil winding counter to begin with?

I want to make my own electric motors which use electromagnetic induction to create motion. My hope is to make pretty high torque motors that’ll require winding electromagnets with 1000’s of turns of coil. Winding electromagnetic coils like this is tedious to do by hand, so I decided to build a coil winding machine; one component of which is a counter to show how many coils have been wound.

Why design it from scratch?

Factory coil winders are big, expensive, and often custom to the job. You can buy manual coil winding machines, but it’s still pretty tedious to wind a 1000 turns by hand. At first, I just Googled “How to make a coil winding counter” and landed on the ubiquitous “hacked calculator” solution.

With the hacked calculator, people have high jacked a calculator’s equals button such that every time a magnet passes by a reed switch, the calculator’s equal button is triggered, which can be set up to increment by one. The idea is to plop a small magnet on your coil winding mechanism and have it increment every time the magnet does a complete rotation and travels by the stationary reed switch.

This is pretty clever and can be put together in 15 minutes or so. The problem with the hacked calculator is that it doesn’t work very well – at least not for the $1 calculator I bought at Target. If the magnet goes by the reed switch at too many RPMs the calculator just starts missing revolutions (see our making a digital counter video at the top of this post for a demo). So, because of this limitation I decided to roll my own counter.

The design of the counter

When I set out to design the counter, I asked:

“What are the key components of a digital counter for a coil winding machine?”

  • For one, we obviously need a display for the count
  • Two, we’re gonna need a microprocessor to keep track of the count and update the display
  • Three, we’re gonna need way to register when a single coil has been wound


The calculator hack used the calculator’s microprocessor and built-in display, with a reed switch for the wind detection mechanism. I decided to keep the reed switch idea for the detection mechanism since that wasn’t what was limiting RPM’s for the calculator.

For the other components, I decided an Arduino would be simple enough to get input from the reed switch and output to a display. For the display, I contemplated ripping out the calculator’s LCD, but decided reverse engineering the LCD or trying to find specs for it online would be too complicated. I could have also got an Arduino shield with an LCD, but I just wanted something super simple so I went with a series of 7-Sement displays that I found at my local Fry’s.

As I talk about in the video, I ran into the problem that the Arduino can only handle 14 I/O’s and I need 7 * 4 = 28 outputs to drive four 7 segment displays. I choose to do four 7-segment displays because I want to make some pretty heavy duty electromagnets with 1000’s of coils, so I figured four digits would get me up to a 9,999 count which should be plenty high.

The solution to this not-enough-I/O problem is to use BCD to 7-Segment chips – NTE 7447s. These little DIP chips are made for use with 7-segment displays, and basically take a BCD bus in and output the right signals to light up the 7-segment. This reduces the I/O necessary for each digit from 7 to 4 (the number of lines needed in BCD to display numbers 0 through 9). Link here for an explanation of BCD if you’re not familiar.

However, 4 digits * 4 BCD bus lines per digit = 16 output pins, which is still too many outputs for a standard Arduino board. I thought about buying the Arduino Mega which has more than enough GPIO pins to handle this, but I wanted to use one of the Arduino’s I had on hand, which were all standard ones.

The solution I came up with after some scouring of the internet, was to take advantage of persistence of vision: to make this work, we would only light up one 7-segment at a time, but rapidly cycle through each of the four so fast that it would appear to our eyes that they are all lit up at once.

The way to do this is to use a single BCD bus of four outputs, and use the enable on the BCD-to-7-Segment chips to turn them on one at a time, several times per second. (See the circuit diagram for more clarity)

As you can see in the video this requires a lot of wiring on a breadboard to pull off. Routing in CAD and printing a PCB probably would have been a better choice for this project, but I haven’t done that before and I didn’t want to learn how to do that just for this project (it’s complicated enough!).

So, in the Arduino code (see github) we detect when a magnet passes by the reed switch and increment the counter:

Then, we send the count to the display routine, which splits up the integer into digits, and then takes each digit and one-by-one puts it on the BCD bus. During each digit’s time on the bus, a single BCD chip is enabled allowing a single digit to be displayed. After some time, the next digit in the count is put on the bus and the next chip is enabled.

After all the digits in the count are displayed, the full cycle repeats:

  • Check the reed switch
  • Increment the count if needed
  • Display the digits in the count one-by-one
  • Loop back

(See the code)

You might be asking “What if the magnet passes by the reed switch while the digits are being displayed?” That’s a great question! Well, the Arduino microprocessor is pretty fast, and the display routine doesn’t take that long. So, the whole cycle completes in such a small amount of time that the RPM of the winding machine would have to be crazy fast in order to miss a reed switch detection. I don’t think I’m gonna be building a machine that’ll push those limits so I’m not worried about it.

What did I learn from this project?

Overall this was a great project – the combination of software and hardware is great for learning how to build and debug a complicated Arduino project. You really have to build this step-by-step like I do in the video and like I show in the step-by-step schematics & code. If you don’t build it incrementally, you end up with bugs that you can’t tell are software problems, wiring problems, design problems, or component problems. The step-by-step approach is the way to go – this project will really push your planning and debugging skills.

What would I do differently?

Not long after I finished this project (I built this last fall but it took a while to get the video and all the supporting materials together), I attended a meetup about how to use FPGA’s. When I was in college 10 years ago FPGA’s and programmers for them were still quite expensive ($1,000+), so I never even considered using one.

Today FPGA boards are less than $100 if you don’t buy latest and greatest, and they can be programmed from your computer just by hooking it up through USB and using free software. Much to my chagrin I found you can even buy boards with 7-segment displays built right in them! (I might do a video on how to use one of those boards down the road.)

Using an FPGA and programming the logic in Verilog would have been much simpler and eliminated almost all of the bug prone and tedious wiring. So yeah, if you’re gonna build this it might be worth your time to learn Verilog and use an FPGA instead.

Other Interesting Projects

If you’re interested in making a coil winding machine at home or other approaches to making a digital counter checkout these projects:

Making this at home

If you want a challenging Arduino project and want to beef up your skills debugging software / hardware combo projects, this is a great project to do. Bonus points if you try to figure out the design based on this blog post and don’t look at my circuit diagrams & code.

I’ve taken care to document this project pretty extensively. See the video for a step-by-step guide and see github for the schematics and code.

Good luck with trying this at home and Happy Arduino Hacking!

Maker, Engineer, and Tech Entrepreneur driven to make Robotics and Making accessible. I make How-to videos on electronics, metal working, 3D printing, etc. Follow me at @cj_windisch on Twitter, Instagram, and Snapchat

About the Author

C.J. Windisch

Maker, Engineer, and Tech Entrepreneur driven to make Robotics and Making accessible. I make How-to videos on electronics, metal working, 3D printing, etc. Follow me at @cj_windisch on Twitter, Instagram, and Snapchat

Leave a Reply

Your email address will not be published. Required fields are marked *