Author Topic: Help with making lights blink at random  (Read 687 times)

0 Members and 1 Guest are viewing this topic.

Offline 1213brettTopic starter

  • Newbie
  • Posts: 1
  • Country: us
Help with making lights blink at random
« on: May 11, 2024, 04:12:56 am »
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.
 

Offline Konkedout

  • Regular Contributor
  • *
  • Posts: 98
  • Country: us
Re: Help with making lights blink at random
« Reply #1 on: May 11, 2024, 04:59:24 am »
"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.
« Last Edit: May 11, 2024, 05:02:20 am by Konkedout »
 

Offline Faranight

  • Supporter
  • ****
  • Posts: 224
  • Country: si
Re: Help with making lights blink at random
« Reply #2 on: May 11, 2024, 05:28:21 am »
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.
e-Mail? e-Fail.
 

Offline Andy Chee

  • Frequent Contributor
  • **
  • Posts: 719
  • Country: au
Re: Help with making lights blink at random
« Reply #3 on: May 11, 2024, 06:35:54 am »
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.
 

Online AndyC_772

  • Super Contributor
  • ***
  • Posts: 4250
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: Help with making lights blink at random
« Reply #4 on: May 11, 2024, 07:42:03 am »
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.
 
The following users thanked this post: Smokey, ebastler

Offline igendel

  • Frequent Contributor
  • **
  • Posts: 360
  • Country: il
    • It's Every Bit For Itself (Programming & MCU blog)
Re: Help with making lights blink at random
« Reply #5 on: May 11, 2024, 08:06:28 am »
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...]
« Last Edit: May 11, 2024, 08:10:19 am by igendel »
Maker projects, tutorials etc. on my Youtube channel: https://www.youtube.com/user/idogendel/
 

Offline Tation

  • Regular Contributor
  • *
  • Posts: 54
  • Country: pt
Re: Help with making lights blink at random
« Reply #6 on: May 11, 2024, 05:39:53 pm »
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.
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7090
  • Country: ca
Re: Help with making lights blink at random
« Reply #7 on: May 11, 2024, 05:57:34 pm »
Just use an Arduino, they have a library function for random() 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.
« Last Edit: May 11, 2024, 05:59:30 pm by floobydust »
 

Online xvr

  • Regular Contributor
  • *
  • Posts: 248
  • Country: ie
    • LinkedIn
Re: Help with making lights blink at random
« Reply #8 on: May 11, 2024, 06:21:08 pm »
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.
Exactly. ESP32 series for example. Relatively simple and very popular. And quite cheap.
 

Offline MrAl

  • Super Contributor
  • ***
  • Posts: 1474
Re: Help with making lights blink at random
« Reply #9 on: May 11, 2024, 09:28:56 pm »
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.

Hi,

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) :)
 

Online Gyro

  • Super Contributor
  • ***
  • Posts: 9610
  • Country: gb
Re: Help with making lights blink at random
« Reply #10 on: May 11, 2024, 09:53:15 pm »
Sorry, I can't resist...

Best Regards, Chris
 

Online jpanhalt

  • Super Contributor
  • ***
  • Posts: 3547
  • Country: us
Re: Help with making lights blink at random
« Reply #11 on: May 11, 2024, 09:56:39 pm »
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=586  I haven't looked at it carefully.
« Last Edit: May 11, 2024, 11:19:35 pm by jpanhalt »
 

Online themadhippy

  • Super Contributor
  • ***
  • Posts: 2674
  • Country: gb
Re: Help with making lights blink at random
« Reply #12 on: May 11, 2024, 11:43:34 pm »
Quote
  Or, reverse engineer and build from scratch.  The investment would be trivial compared to some of the other options.
Might 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.
 

Online jpanhalt

  • Super Contributor
  • ***
  • Posts: 3547
  • Country: us
Re: Help with making lights blink at random
« Reply #13 on: May 11, 2024, 11:58:32 pm »
Quote
  Or, reverse engineer and build from scratch.  The investment would be trivial compared to some of the other options.
Might be a bit of a problem finding the custom microprocessor.

You 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
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf