A simple kids toy for a beginner - vibration sensor + 555 timer + CD4017 - Page 1
Forum section: electronics / beginners

author: Agent47
author_rank: Newbie
timestamp: September 23, 2025, 09:35:44 pm
content: I am new to electronics and would like your help designing a simple kids toy.My intention is to use a vibration sensor like the SW-18020P, to make a linear set of 10 LEDs flash simultaneously for 5 seconds. Once every 0.5 seconds.I have been reading about using a 555 timer configured as an astable at ≈ 1 Hz. The 555 timer will trigger the CD4017 to count to 5, before being disabled.I plan to use 3x AA batteries for a total of 4.5 volts in the project.As a complete novice, I am asking for guidance in designing this project and finally to produce a PCB.

author: Analog Kid
author_rank: Super Contributor
timestamp: September 23, 2025, 10:47:24 pm
content: Sorry can't help more, but just wanted to say that it looks like you're on the right track here.One thing missing is the 0.5Hz flashing circuit. Another 555 would take care of that. (Get a dual 555.)Since the 4017 is a low-power device, you'll only be able to drive the input to another chip (like the 555 used as a flasher). Can't drive the LEDs directly from it.Others here will be able to give you more detailed help.Sounds like fun.

author: brucehoult
author_rank: Super Contributor
timestamp: September 23, 2025, 11:57:19 pm
content: That's definitely how I would have done this in High School lunch time electronics club in 1977, building it on Veroboard.Today .. I'd use a $0.15 16 pin one of these and write a few lines of C code. One chip type can replace a whole catalogue of 7400-series, at least for low speed applications e.g. 1µs latency is ok, you don't need 5ns.https://www.aliexpress.com/item/1005005036714708.htmlOr a ready-made $1.50 breadboard-compatible board like this...https://www.aliexpress.com/item/1005005221751705.htmlWell, just a thought. It's good to know how to use SSI chips or even transistors too.

author: golden_labels
author_rank: Super Contributor
timestamp: September 24, 2025, 01:32:34 am
content: Quote from: Agent47 on September 23, 2025, 09:35:44 pmWelcome to the forum!You must ask yourself a question: what is your goal? Choose between the two options:The goal is to have fun while creating the toy, regardless of the final result.The goal is to create the toy, so the finished device can offer some fun.If it’s the first, then the idea sounds reasonable. In principle it may work. If you discover any issues, that will be more fun and experience gained for you.If it’s the second: go for a microcontroller. Your idea is plausible and seems trivial. But it may have some hidden obstacles that will slow you down or needlessly complicate the project. It’s possible to implement logic using discrete components. History shows us beautiful designs, that rely on elements simpler than proper logic ICs. But there are traps each time one tries to implement logic incorporating:Feedback loops.Handling unexpected inputs.Both require a carefully designed state machine, that can deal with timing issues and invalid states. With a microcontroller the first half is already solved, the second is much easier to handle.

author: Analog Kid
author_rank: Super Contributor
timestamp: September 24, 2025, 02:04:41 am
content: I like going the discrete/non-microprocessor route, but that's just my preference.However, it was also what the OP actually asked about, so with that in mind, here's my take:You should be able to do this with just 4 chips (actually 3 if you use a dual 555):The vibration sensor triggers the one-shot (official term: monostable) which sets the 4013 flip-flop.This starts the 555 0.5 second timer which flashes the LEDs, and also sends clock pulses to the 4017 counter.When the counter counts to 10 (10 X 0.5 = 5 sec.) it sends a reset pulse to the flip-flop which turns the whole thing off.(Kind of like the "little black box" from the Addams Family TV show, where the hand reaches out and shuts itself off.)Advantages:Fun (at least to people like me)No programming necessaryFairly simple constructionDisadvantages:There may be timing issues as noted aboveAny "tweaks" would have to be done by rewiring, not just reprogrammingMay consume more power than a microprocessor, which can go into "sleep mode"

author: RJSV
author_rank: Super Contributor
timestamp: September 24, 2025, 03:34:40 am
content: Welcome. You can also drive a transistor base input to get a couple hundred mA (like 0.250 Amps or '250 milli-amps'). With 2n2222 transistor you would connect one LED to positive supply, say with 220 ohm resistor in series, to the transistor 'collector' and transistor emitter to ground (- side). Then, with 5 VDC supply, you get: 5-2 = 3 volts, roughly across that 220 ohm resistor, (neglecting the small drop of the transistor).I = V/R. so that I (current) is roughly 3/220 = 14 mA with that resistor value in series.The 2n2222 is for positive drive....I'll need a second to check if 2017 outputs are low-active....(wait)

author: RJSV
author_rank: Super Contributor
timestamp: September 24, 2025, 03:52:53 am
content: We're ok as the CD 4017 decoded to an active high on each output.(Many TTL types are the other way, going to zero volts when active).So, the active high of each output is used to drive the base of each respective buffer transistor, typically a 2N2222. By the way, a 2N2222 is usually seen as a small rounded package, when it's a through hole mounted type. Holding the thing, while the flat face is towards you, you can identify: emitter base collector, or just E-B-C for connecting.I would hate to let you try looking something like that up. Texas Instruments overwhelms myself, with junky 'IC Family' info overload.Ditto for attempting to program 'simple' microprocessors.Even at 1 cents per IC you would still have to wade through a large 'learning experience's including purchase or otherwise obtaining a downloaded compiler. Nice way to learn C coding, but OMG, the bulk you have to endure,...endless little details to just obtain the software.Not that the uP route is bad, mind you. Just bulky to aquire and code.Eventually, a good thing.Obtain a cheap oscilloscope is a very useful adjunct activity.AND, finally, ask your questions, here, as needed !

author: RJSV
author_rank: Super Contributor
timestamp: September 24, 2025, 04:03:26 am
content: Oh yeah, (sorry), you will need a base resistor as well. I'd start with a 2 kohms (2,000). You could try various values for a dimmer or brighter effect, or alter the LED limiter resistance to higher values, to dim the overall brightness.I absolutely love the decoded CD4017 ! Your 555 IC will come in various flavors, of power output, CMOS, etc.Try walk around (any) modern toy store, to maybe buy and explore the innards. Some toys have lots of relatively safe circuits, to handle and scope out !

author: ledtester
author_rank: Super Contributor
timestamp: September 24, 2025, 04:24:09 am
content: Here is what I came up with.. uses two 555s and a CD4017:(Falstad simulation)Press the TRIGGER switch to get things going.The left 555 is just a standard astable. The right 555 is used as a SR-latch. The Q output determines if the clock is running. When Q6 goes high the SR-latch is reset.You can take CLK as being the output. There are two (perhaps minor) issues:1. The first CLK pulse will be slightly longer than the others due to the 555's cap not being charged up.2. Falstad shows a very short runt pulse at the end. Might have to look at it with a scope to determine how big it is.You could also take -CLK^Q as the output. Then you would avoid the longer initial pulse but it would start a half second after the trigger is pressed. In this case Falstad shows a runt pulse at the start of the pulses.

author: Analog Kid
author_rank: Super Contributor
timestamp: September 24, 2025, 04:57:23 am
content: Nice. 2 chips.

author: golden_labels
author_rank: Super Contributor
timestamp: September 24, 2025, 06:26:42 am
content: It doesn’t retrigger correctly, if the vibration sensor is active on the last pulse’s falling edge.

author: gbaddeley
author_rank: Regular Contributor
timestamp: September 24, 2025, 07:41:34 am
content: The counter could be replaced by another 555 set as a one shot 5 seconds.

author: themadhippy
author_rank: Super Contributor
timestamp: September 24, 2025, 09:58:40 am
content: Why the 4017? unless im reading this wrongQuote2 555's is all thats needed, one to do the 5 second timing trigged by the switch and firing the second for 0.5 flashing,transistor hanging off its output to drive the leds.Quotecan you squeeze another AA in there to end up with 6v? 4.5V is right at the bottom of the 555's voltage range ,with partially used battery and voltage drop caused by the contacts and wires you may find things not working as you expect

author: Agent47
author_rank: Newbie
timestamp: September 24, 2025, 03:09:49 pm
content: Wow! I am blown away by the interest and help.We can definitely play with the parameters. The design has accommodation for an extra AA, totalling 4.I have read the suggestions from themadhippy to use 6V and two 555 timers to drive the LEDs.I am not sure how to connect it all.

author: RJSV
author_rank: Super Contributor
timestamp: September 24, 2025, 05:23:15 pm
content: I will get a summary schematic soon, for your use.If you end up using a transistor, for each of the LED's you can consider GAIN parameters, informally. Messing around with the voltage and current, can get hard to understand, on a transistor, with logarithmic math and all. But, as a short-cut when switching many folks just assume a GAIN of 100.That just means that (your) task is just consider the BASE to Emitter current times the GAIN will be the output current. The output, in this so-called 'Common Emitter' circuit is the transistor Collector. Mentally, a technician will consider things as two separate items; input by way of base to Emitter, and output by way of collector to Emitter.No shortcuts on OHM's Law though. You need to at least know that:1.). V = IR. Variation is. I = V / RThat's V for volts (buy a meter !).I is symbol for current.and. R is resistance. (If you don't know already.)So, with a 2 kohms base resistor in the input, and 4 volts applied as input, you get roughly 3 volts across 2 kohms. That's because the base to Emitter puts up a fuss, of a usual 0.8 volts back-voltage, when you drive it. So I subtracted (roughly 4-3).Anyway, that would be an input current of V / R:I = 3 / 2000 or about 1.5 mA into the base (relative to gnd. or common).So, 1.5 mA X gain of 100 allows for 150 mA on the collector circuit.It's really used as a switch, rather than an analog thing you would use with music or variable dimmer.Simple schematic next....

author: ledtester
author_rank: Super Contributor
timestamp: September 24, 2025, 06:22:47 pm
content: Quote from: golden_labels on September 24, 2025, 06:26:42 amIf you use just a simple vibration switch I don't think that's much of a concern since they jiggle around a lot.But, here is a modification which will retrigger if the switch is held pressed throughout the last pulse.(Falstad simulation)

author: ledtester
author_rank: Super Contributor
timestamp: September 24, 2025, 07:49:54 pm
content: Here is an implementation of the 2x 555 idea (sans the 4017):(Falstad simulation)R2 controls the pulse duration and R1 controls the 5 second timer.

author: RJSV
author_rank: Super Contributor
timestamp: September 24, 2025, 09:55:49 pm
content: ...But I thought you wanted to sequence through the LEDs, (not all flashing together)?

author: Analog Kid
author_rank: Super Contributor
timestamp: September 24, 2025, 11:05:54 pm
content: Quote from: ledtester on September 24, 2025, 07:49:54 pmOne chip! Going once ... going twice ... SOLD!

author: RJSV
author_rank: Super Contributor
timestamp: September 25, 2025, 08:27:59 pm
content: If you are choosing the cd4017 as most folks do, it's chosen due to uncoded ability, to do one output after another, in so-called 'un-coded' or could be called 'one after another'.Contrast that with 'encoded', where all the signals are in a group. With the encoded variety, you cannot skip over any of the signals:Think of it like this:Decimal number '101' still needs that zero, or you wouldn't get the totality of it. Uncoded, on the other hand, only uses one and only one 'ON' bit, or more correctly 'flag',...so you know the value fully, and can ignore the other signals in your set, (once you've spotted the one).

author: Agent47
author_rank: Newbie
timestamp: September 29, 2025, 09:02:37 pm
content: Thanks to all the contributors up to this point.I have tried to breadboard the solutions, but I am failing miserably. Chuck it up to being a complete beginner. I am probably missing something basic...In scouring the internet for alternatives, I stumbled upon an interesting blog post at Gas station without pumps:https://gasstationwithoutpumps.wordpress.com/2015/03/28/ideas-about-vibration-detection/In the post the author proposed a redesign the SparkFun “Wake on Shake” device. Instead of a ATtiny2313A microprocessor, is circuit uses a comparator, TS881, and a DMP1022UFDE MOSFET. This results in passive timing using RC decay.Looking at my local electronics shops inventory, the TS881 and DMP1022UFDE is not available. So I will have to special order them... alternatively the TS881 could be replaced with a LM393 using a 47kΩ pull-up resistor from the comparator output to VddFor the DMP1022UFDE one could substitute it with a IRF9540.The plan is to use the analog “Wake on Shake” to trigger the flashing of LEDs.Would this even be possible?

author: ledtester
author_rank: Super Contributor
timestamp: September 29, 2025, 11:37:19 pm
content: I suggest building the circuit in stages.Start with the lower 555 (the one where OUT goes to the transistor) but connect RST to +5 instead of to the other 555 (since we're omitting the upper 555 for now). The OUT pin should pulse on and off. To see this just connect a 1K resistor and LED to it like this:OUT --- /\/\/\/----|>|---GND1K LEDThe next step would be to add in the transistor to drive one LED.Then have the transistor drive multiple LEDs.Then we can work on the upper 555.