Help with making lights blink at random - Page 1
Forum section: electronics / beginners

author: 1213brett
author_rank: Newbie
timestamp: May 11, 2024, 04:12:56 am
content: Hello! I know nothing about electronics and joined this forum just to ask this question. I am a martial artist. I want to make a punching bag with multiple lights. I need each light to light up one at a time at random So I can use them as targets for striking. How hard would this be to do and how would I go about doing it. I would appreciate any help or advice on the matter.

author: Konkedout
author_rank: Frequent Contributor
timestamp: May 11, 2024, 04:59:24 am
content: "Random" is one of the more difficult things to achieve electronically. Microsoft Excel can generate a "random" number which I think is actually pseudo-random. Anyway pseudo random is a digital technique. I design analog and power (not digital electronics) so digital pseudo random number generation is far "outside my wheelhouse."One true random technique would start with some sort of noisy analog source. I am pretty sure this is possible. If I were to do this, I would need to start with some experimental work on the lab bench.But neither approach is a trivial design. Probably neither is a good task for a newbie.

author: Faranight
author_rank: Unknown
timestamp: May 11, 2024, 05:28:21 am
content: Just use a small microcontroller with at least two timers that have different clock sources. You can use the timer jitter between the two sources as a source of entropy for the pseudo-random number generator that you're going to use so that the lights don't always light up in the same order. Then write a program that controls several digital outputs, which in turn control the individual lights on the dummy. I see this could be a nice beginner Arduino-style project. I've successfully used Atmel micros in this manner for a Christmas LED lights blinker.

author: Andy Chee
author_rank: Super Contributor
timestamp: May 11, 2024, 06:35:54 am
content: For the purpose of randomising punching targets, I think a free running 8-bit counter at 100kHz would be more than capable of generating sufficient randomness for testing human reaction.Alternatively, a reverse biased diode noise source connected to an 8-bit A/D converter would be genuine randomness.

author: AndyC_772
author_rank: Super Contributor
timestamp: May 11, 2024, 07:42:03 am
content: The task of generating numbers that are random enough for this application is trivial. Just run a fast timer, and when one pad is struck, capture the bottom few bits of the timer and use that to pick the next target. Unless you can strike a target with a consistency that's within fractions of a microsecond - in which case you don't need any further training!! - it'll appear completely random.This project needs a microcontroller, a few lights, and a way to tell that the bag has been struck. The electronic part is easy; the hard part will be mounting the lights and sensors in a way which is robust and reliable. If I were doing this, I'd expect to spend about 75% of the time on finding lights that are robust enough to survive a kicking, and mounting them in such a way that they don't fall off. You don't want cables coming loose that you could get tangled in.

author: igendel
author_rank: Frequent Contributor
timestamp: May 11, 2024, 08:06:28 am
content: A classic "random enough" generator is the one used in the old Simon memory game: the microcontroller measured the number of milliseconds it took the player to start responding, divided it by 4, and used the remainder to select the next light in the pattern to be memorized. This can be easily adapted to punching.Also, this question reminds me of an old punching project of my own:Part 1 - the device:Part 2 - a demonstration:[Edit: You'll note that there are some "misses"; some because of the sensor, some due to the poor communication hardware...]

author: Tation
author_rank: Regular Contributor
timestamp: May 11, 2024, 05:39:53 pm
content: Sure there are many solutions based on counters, but there are also plenty of modern MCUs equiped with random number generators, many times true RNG (TRNG), suitable for crypto applications, that will solve the problem almost out of the box.

author: floobydust
author_rank: Super Contributor
timestamp: May 11, 2024, 05:57:34 pm
content: Just use an Arduino, they have a library function forrandom()that is way less hassle.You would also want to control the blink change rate with say a potentiometer, so that is again easy with a microcontroller in software.It's also possible to add piezo sensors to measure how hard and fast you are hitting the punching bag, just like electronic drum pads use.

author: xvr
author_rank: Frequent Contributor
timestamp: May 11, 2024, 06:21:08 pm
content: Quote from: Tation on May 11, 2024, 05:39:53 pmExactly. ESP32 series for example. Relatively simple and very popular. And quite cheap.

author: MrAl
author_rank: Super Contributor
timestamp: May 11, 2024, 09:28:56 pm
content: Quote from: 1213brett on May 11, 2024, 04:12:56 amHi,First, you do not need a true random number generator for this you can use a pseudo random number generator, and that is one using digital logic.The way these are done is with a sort of digital polynomial, which can be generated with simple exclusive OR gates (XOR gates). You just wire up the gates in a certain way and the output is a random string of 1's and 0's.Using a microcontroller is very common these days and not too hard to learn, and it makes things very easy. If there is a built in function for generating a random number you can use that as others have mentioned. If not, no big deal, you can create code that looks like exclusive OR gates (XOR) and arrange it to output a random number of any number of digits. That way would allow you to start with ANY microcontroller you want with no boot loader or anything like that, and with some simple code, start generating random numbers. You can even create a white noise generator doing it that way.Good luck with your new makiwara board (that's the Japanese name for it although it may not have actually originated in Japan)

author: Gyro
author_rank: Super Contributor
timestamp: May 11, 2024, 09:53:15 pm
content: Sorry, I can't resist...

author: jpanhalt
author_rank: Super Contributor
timestamp: May 11, 2024, 09:56:39 pm
content: Basic question: How many LEDs do you want to use?EDIT: Since you "know nothing" about electronics, using a microcontroller is probably not going to happen unless someone does it for you. In the 1970's, there was a popular game called Simon (https://en.wikipedia.org/wiki/Simon_(game)) that had 4 lights that blinked pseudo-randomly under switches. The players tried to be the first to hit the lighted switch. Sounds like what you want to do. They are available on eBay for about $8 each. You could buy whatever number needed and repurpose them to flash LEDs. Or, reverse engineer and build from scratch. The investment would be trivial compared to some of the other options.EDIT2: The schematic for Simon was easier to find than I guessed. Here's a link:https://www.waitingforfriday.com/?p=586I haven't looked at it carefully.

author: themadhippy
author_rank: Super Contributor
timestamp: May 11, 2024, 11:43:34 pm
content: QuoteMight be a bit of a problem finding the custom microprocessor.As for cost an ardunio clone like the LG8F328P are dirt cheap,the most expensive bit will be the leds and switches that can take the abuse ,maybe look at the arcade machine market.

author: jpanhalt
author_rank: Super Contributor
timestamp: May 11, 2024, 11:58:32 pm
content: Quote from: themadhippy on May 11, 2024, 11:43:34 pmYou can get a pre-programmed one here:https://www.ebay.com/sch/i.html?_from=R40&_trksid=p3519243.m570.l1313&_nkw=simon+game&_sacat=0