[Beginner] Divide the frequency by two with 74HC74 (D-type-flip-flop)

Hello everybody ! :slight_smile:

First of all let me apologize for my bad english (I'm french, and yes I know there is a french forum but I think that I will get more help here).

I'm a beginner in Arduino (I'm just starting, I have Arduino classes since 2 weeks) and I have 4 projects to prepare for Monday, but there is one that I can't do at all... For every projects we need to know the code in Arduino language and we have to know how to do it on the Arduino Uno.

The Project I can't manage to do is to divide the frequency delivered by the Arduino by two, using a 74HC74 which is a D-type-flip-flop (so I have to create a "frequency-by-2-divider").

The thing is that I have no idea where to start. For the 3 other projects that I managed to do I could train on www.tinkercard.com but there isn't the 74HC74 on this site, and I can't find many informations on Google (I've been searching in french and english).

So if someone has an idea about the lines of code I have to write and/or about the Uno circuit I have to do, that would be amazing !

Thanks a lot (and again sorry for my english), and have a good day ! :slight_smile:

Hi!
Are You forced to use 74HC74? You could use any digital counter/divider. The 74xx74 can do many different things. it is very fast and also sencitive for disturbance so it was baned in military constructions.
I designed a digital clock using plenty of 7474 more than 40 years ago but sorry, I don't remember how to use the set/reset and j,k to make a divider. Set/reset was forced HIGH I think. J and K are used in some way. It must be possible to find in application handbooks.'
Regards,
Railroader

Try this search term: divide by two circuit

So if someone has an idea about the lines of code I have to write

There is no code to write, it is hardware.
The 7474 has two D-type flip flops in it both can act as a divide by two circuit.

Simply connect the D input to the Q bar output. Then apply the signal to the clock input and half the clock frequency will be on the Q output.

Connect that output to the clock of the second flip flop again with D connected to Q bar and you will get a divide by four circuit.

Thank you for your answers.

Is there something that works like a D-type flip flop on www.tinkercard.com (or some other website if you know them, where we can create circuits online, because I don't have this at home) so I can try to do the circuit ?

Thanks ! :slight_smile:

Is there something that works like a D-type flip flop on www.tinkercard.com

I have no idea, I don't use simulators. Seems like a total waste of time to me.

If you want to make a D-Type flip flop you can do it with logic gates. Here is an all NAND gate design from a book I wrote on logic.

Thank you. I use a simulator because I just started classes of Arduino and I don't have any stuff at home so I think it's useful for me. :slight_smile:

Maybe this'll work for you: Logic Gate Simulator.

I think you'll have to recreate @Grumpy_Mike's circuit to realize a flip-flop.

So I tried but I have some problems.

I realized a circuit which makes a LED blinking every 500ms, but I would like to add another LED near it with the 74HC74 type-D-flip-flop, in order to make the 2nd LED blink twice slower (so I guess that if I do that I would have realized a frequency by-2 divider), but I don't understand how to make the circuit (so with the 74HC74 and the other LED).

Thanks a lot ! :slight_smile:

Is there something that works like a D-type flip flop on www.tinkercard.com

What software are you running? That site seems just to be links to other stuff and I can’t see an Arduino simulator.

You need to run the software dougp linked to, or something like it.

I'm not using any software, it's online on www.tinkercard.com and then you click on "circuit" and you can create your own circuit (the screenshot I sent was something I did on this website for example).

I'm not using any software, it's online on www.tinkercard.com and then you click on "circuit" and you can create your own circuit

Not when I visit the site it dosn't.

I put www.tinkercard.com into the URL bar and I get redirected to http://ww1.tinkercard.com/?sub1=2fd84e18-2532-11e8-b189-5aa6220056b0

It looks like this:-

Their is no "circuit" link and you will see the domain is for sale.

That's strange...

Does it work if you click on this : Tinkercad | From mind to design in minutes ?

You might have to create an account by the way, but in France the domain is working good idk why.

I still have a question about how to connect the D-type-flip-flop (on the left of my BreadBoard) in order to divide the frequency by 2 in the 2nd LED (for the moment, they both blink at the same time, and I think that my goal is to make the 2nd LED (the one in the left) blinks twice slower than the first LED (the right one), because I guess that it would mean that I manage to divide the frequency by 2)...

I need your help ! :slight_smile:

Does it work if you click on this : Tinkercad | From mind to design in minutes

No. I get a “this page has expired ... get me out of here” message, which is what you get with trogon web sites.

Anyway it is unlikely you can do your problem with this emulator if it does not have active components.

and I think that my goal is to make the 2nd LED (the one in the left) blinks twice slower than the first LED (the right one), because I guess that it would mean that I manage to divide the frequency by 2)...

That is nothing like the problem you first posted. Sure you can make one led blink at half the rate of the other but that is nothing to do with a D-type flip flop.

To make the second led blink at half the rate simply increment a counter on each loop and output to the first led the first bit of the count and output to the second led the value of the second bit of the count.

Look up the bit read function.

My main (and only) goal is to create a frequency divider (dividing by 2), using the 74HC74, which is a D-type-flip-flop.

So in order to show the teacher that I managed to do this, wouldn’t it work if I do a circuit with two LED, one which blinks every 500 ms and the other every 250 ms, but without changing the line of codes ?

That will show that I managed to divide the frequency by two between the first and the second LED right ?

But I don’t know how to put the wires on the D-type-flip-flop (there are 14 pins on hit, “VCC”, “2RD”, “2D”, “2CP”, “2SD”, “2Q” and “2NQ” on one side, and “1RD”, “1D”, “1CP”, “1SD”, “1Q”, “1NQ” and “GND” on the other side).

I tried doing this (I saw something like that on Internet), but the 2 LEDs still blinks at the same time (you can see the code next to the circuit) :

On the D-type-flip-flop, the black wire goes from “1D” to “1NQ”, the green (which starts in the Uno) goes from Pin 9 to “VCC”, and the last green wire goes from “1Q” to next to the resistor.

If know how to do it it would be great !

Or if you know another (easier) way to show the teacher that I managed to divide the frequency by 2 using a 74HC74 D-type-flip-flop, it would be great too !

Thanks a lot ! :slight_smile:

But I don't know how to put the wires on the D-type-flip-flop

Vcc to 5V
Gnd to the Arduino's ground.
CLK1 to pin 9 of the Arduino
D1 to ~Q1 ( that is pin 6)
CLR 1, PR1, to 5V
LED through a resistor to Q1.

I hope I get a good mark for this homework, how much of a mark do you think you deserve?

Thanks a lot sir !

Well, to be honest I will have a test on one of the four projects (randomly) and I did 3 on my own, but I'm not good at all with the Arduino, and I have never seen the 74HC74 D-type-flip-flop so it was really hard for me to understand how it works.

Moreover, I just started Arduino classes 2 weeks ago, before that I never touched anything like that.

But you're right, I don't deserve it, but hopefully I will improve, I just need more classes and to watch/read some tutorials.

So I did this, and when I launch the program (the code is next to the circuit), the 2nd LED blinks every time the 1st LED blinks twice, so I guess that it's OK, I (you) did a frequency divided (by 2) with 74HC74 right ?

Thanks again a lot Grumpy_Mike ! :slight_smile:

I (you) did a frequency divided (by 2) with 74HC74 right ?

Yes right. :slight_smile:

FYI, @Grumpy_Mike’s circuit does create a functional D type flip-flop in the software I linked.

Do you know what a datasheet is?

FYI, @Grumpy_Mike's circuit does create a functional D type flip-flop in the software I linked.

Must be very poor software then.
I wrote a logic simulator many years ago and that circuit does work, as it also does if you make it with real gates.