Using to divide pulses

Any ideas how to read a stream of clock pulses then divide those pulses by said amount and send them to an output, this will be my first sketch and I think I will be ok with setting up the pins but it is the division part that I can’t figure out. So in essence what I would like to do is read a stream of fast pulses then capture the first and output a pulse from one of the digital output pins, ignore the next 3 incoming pulses then capture and output the fourth, ad infinitum.



Hello adorkisme!

If you have started to code, post the code (using the [#] button when posting) this way it will be easier for us to see what we can help / contribute with. If you have no code, or no idea how to implement a thing like this:

Break it up into smaller problems.

Play with division.
Familiarize with division on bytes and ints and the modulo as well as division on floats / doubles.

Try to capture input.
Try to log a series of inputs.
Try to accomplish a hardcoded version of your output. So you’ll know what it takes.

I would love to help out, but it is hard when I do not know more about the problem :slight_smile:

another approach is to use attachInterrupt :

This calls a function on when a transition (on pin 2 or 3) is detected. In this function you can increment a count and check if the count is 4, if so you set your output pin high. If the count isn’t 4 you set the pin low. This should give you the output you want.

What are you making?

Thanks guys, I am not at the coding stage yet, I am a complete newb so at the moment I am just in awe that arduino could potentially allow some very cool things once I can get my head around it.

I have just bought the Make book “Getting started with Arduino” and a freeduino board, I have never had any experience with programming (well except for 1 very basic thing I did on a Psion3 many years ago)

I must admit I am finding it a little difficult to understand how things fit together, so far I understand the basic structure like setup and loop and the real basics like defining pins and the like.

The project is to take a pulse from an old drum machine and divide it to allow it to sync another machine, I think the drum machine spits out a 5v 2ms pulse 96 times per bar and I would like to convert it to 24 or 16 pulses initially.

But in the meantime thanks for those pointers, as soon as I have some (probably wonky) code I will post it.