LED strip project

Hi all

I am pretty much entirely new to this. I found a YouTube video talking about how to power an led strip with a raspberry pi which was super helpful, but could do with some guidance.

This is what I’m trying to replicate:
Tempostik

It’s a fairly simple led strip which lights up leds in a specific way to show tempo for a golf shot. Thing is they want GBP500 for it and it’s only on android. It’s much cleverer than what I need too I suspect. Just looking to be able to control an led strip about a meter long and with it lighting up one at a time.

I however have no clue what I need to make this thing. Any hints or tips would be hugely appreciated :slight_smile: thanks!

1 Like

Hi Michael,

Are you trying to build this from scratch? Off the top of my head you’ll need an LED Driver, some (likely weatherproof) LED strip lighting (I’d suggest using some WS2812B’s or something similar), an accelerometer or similar method to measure or calculate the impulse, some form of battery to act as a power supply, as well as a microcontroller or two in order to control the system reading the sensor and outputing the appropriate data to the LED strip (which can be done quite easily with a free public library of code depending on which microcontroller you choose).

1 Like

Thank you! Yes I’m trying to build it from scratch. It’s going to live indoors so I don’t think I need to worry about waterproofing. From what I’ve looked into I think it’s the coding that’s going to be the hard part. That and figuring out the timing that I need, but I think that will be an interesting exercise. I have a WS2812B on its way and I got an elegoo mega starter pack (was cheaper than the uno one for some reason).

I’ve found some super helpful videos on YouTube (like this one: Arduino Workshop - Chapter One - Hello World Example - YouTube) to get me started, but I’m wondering how to do the more complex parts of my code. Here’s the thing:

I want the led to start in the middle and do red, wait one second, yellow, wait one second, green, wait one second and then turn purple and start to move. That’s all fairly easy I think, but the hard part is when it moves each step is going to have a different delay (which I still need to figure out) so I’m not sure if there is a way to set up a table with all the delays in it or if I just have to put in 100 lines of code with the delays in between. That’s going to make troubleshooting or adjusting it really hard vs the table thing.

2 Likes

You can use a loop of some description with a variable that increments according to some function in order to implement that, it’ll be only a few lines of code to do so depending on which language you go with (I’d suggest grabbing a board that supports a Pythonic style of language, such as Micropython if it’s your first time)

Hi All

The LED strip might be fairly simple but the driving of them certainly would not be. Has anyone thought what goes into a golf swing, even a putter which this is earmarked for. The clubhead should accelerate through the ball and decelerate after the strike with the follow through. The LEDs have to replicate this. There are that many variables to consider it is a bit mind boggling. Then what is considered to be the perfect putting stroke to suit these conditions has to be generated. How do you decide this? There are undoubtedly models out there but they would not be cheap and way beyond the home hobbyist I think but I applaud you for even thinking about it and trying.

Maybe there is a reason for that £500 price tag.
Cheers Bob

Well that’s the thing. I think coming up with an equation that mimics a putting stroke would be nigh on impossible, but someone with patience could figure out the timing by watching a great putter on video and timing it by frame. Then interpolating to get the right delay between each led lighting up and going out. There are certain guidelines about how long backstroke and downstroke should be that will help to put it within certain ranges. Then a bit of trial and error and I think it’ll be done.

The issue I have is that trial and error is going to be painful if I have to go and find the specific piece of code for the gap between say led 28 and 29 and update it. What would be nice is if I could prepare a table in excel and then copy it into my arduino ide and have it look that up somehow.

A table is one way to go. The programming required to cycle through an array of data, picking out each value in turn, is quite straightforward, but the process needs careful design. If you think about the process as a series of steps through the swing, then at any one time each LED will have a colour (including black, or off). Obviously you can’t describe the whole string at each instant, but you can describe the time at which any change occurs. The question is, what information do you have to maintain in the table to describe that change?

If the display was just a band of lighted LEDS running from one end of the strip to the other, then the process is fairly simple. The table contains a list of events describing the time at which the event needs to occur, the LED involved and the new colour information for that LED. Each time around the loop you look at the next item in the list and compare it to the clock. If its time has arrived you set the indicated LED to the indicated state, and check the next event. In the simplest version this state would be on or off.

The display strip is controlled by an array with one element for each LED. To change the display you adjust the array element to its new state and transmit the entire array, so if you know the new colour for the LED that just changed, that part is easy.

With careful calculation of the table values you can have a display in which the lighted band of LEDS moves at a particular speed along the strip, and also changes in length. As the lighted band simply moves from one end to the other, you have two table entries for each LED. That’s probably a manageable table.

If the display is a little more complex, such as a length of white LEDS indicating speed and a section in the middle of red LEDs indicating the position of the putter, then each LED could change state four times (white, red, white, off), and the table of events is twice as large. If you want the LEDS to fade in and out (for example) then a table becomes impractical.

The alternative to the table is an algorithm that calculates putter position and speed at each tick of the clock and uses that data to select the required colour for each LED based on the relationship between the LED position in the string and the parameters - that is, colour for each LED is selected based on the LED distance and direction from the putter position and the current putter speed. If you want to also display the position of the ball, that becomes an additional calculation. That’s probably how the product you have referenced does it, and is effectively what you describe for making the Excel table. It provides the greatest flexibility, but as every LED is recalculated at every tick of the clock, you would need a fast processor.

1 Like

Hi All
I will just throw another parameter in here. “Normally” (is there a thing called “normal” in golf) the force applied when hitting the ball and thus how far it will travel under a multitude of conditions is “usually” directly related to the distance of backswing and follow through so the number of LEDs used will vary also.
One of the tips on improving putting technique may help here. It goes like this.
Follow through about 150% of backswing.
Work out a rhythm which you can count in your head. Like “1 and 2” for the backswing “and 3 and 4” or something like that for the strike and follow through.
Keep this rhythm and change the distance of backswing etc to adjust force ; say 5 or 6cm backswing and 7.5 or 9cm follow through for a light touch and corresponding increases for more force, the timing remaining constant.
You will see here if this method is followed the CLUB HEAD SPEED and thus the striking force will increase as the backswing and follow through distances are increased.
I might add here that if you are having putting problems (as we all do) this method does work and I think that is what this linked device is designed to do.
Hope this helps a bit.
Cheers Bob

1 Like

Thank you! I have my timings. I’m thinking to light one led at a time. So at each move I need to turn on one light and off one light. At least for now. As I get into it more I may try to include some kind of tail or similar. I can do a program that will work. Basically

Set led 72 to red
Wait 1000ms
Set led 72 to black
Wait 1000ms
Set led 72 to yellow
Wait 1000ms
Set led 72 to black
Wait 1000ms
Set led 72 to green
Wait 1000ms
Set led 72 to black
Wait 1000ms
Set led 72 to white
Wait 1000ms
Set led 72 to black
Set led 73 to white
Wait 50ms
Set led 73 to black
Set led 74 to white
Wait 35ms
Etc

As you can see this is pretty time consuming and tedious. I’d have a table with three columns (and for this particular swing 124 rows). One to say which led to turn off (which would always be the one from the previous step), one to say which led to turn on (which would always be +/- 1 from the previous step) and then one to say how long to wait before moving to the next step. I don’t think I need to pass anything to the other 142 leds to say stay off, but I may be wrong or that may happen in the background of the programming language (FastLED).

Given the specific nature of which led to turn on and off, I could potentially use a for loop to iterate through it. Then I’d need a formula to match my timings and if I could parameterise it then I could adjust it for different lengths of swings. I imagine that’s what they’ve done to make the for sale version. Someone put a lot of thought into doing it.

I think I’m just going to brute force my first go and then I’ll think more about it once I have the kinks ironed out.

2 Likes

You would start with all LEDs off: you only need to handle LEDs that change their colour.

A table of LED#, colour, delay would work (delay could be zero), but my preference would be a table of time, Led#, colour which would be easier to program and more flexible. Your code keeps a pointer to the current place in the list. You check that list item in a very tight loop, and if its time has arrived (according to the internal ticker) then you set the LED to the indicated colour and increment the pointer. That way errors in the timing do not accumulate, because if the code isn’t fast enough to get to the next event on time then it just delays that event, not the subsequent ones. It’s more flexible because it doesn’t make an assumption about what else needs to happen at each event.

Either approach could be parameterized by using a multiplier in conjunction with the timing information.

It is always recommended to build the project using baby steps, so a brute force example that just runs a light up and down the string is a good way to start.

1 Like

Well - brute force method engaged. Pretty pleased with how it came out. Attaching a video of it in action (or I would if I could figure out how to do it). Timings need a little tidying up, but I used Brad Faxon as my model (by which I mean I watched him on YouTube and guesstimated the delays).

1 Like

Wow looks pretty hard to replicate that LED strip light, did you manage in the end? How much was the cost?

Hi, How did you get on with this project?

I went for a putting lesson and we used this training aid to help with tempo and speed control. I was curious on how easy it is to build something similar considering the cost of the real thing.

I would be grateful if you could share details on the hardware used and any scripts used.

thanks

4 Likes