Good Day! thus fastled libraries has a tutorial on how to make a countdown using individually addressable led strips?. i want to create a project that is a seven segment display. each segment contains 5 leds. how can i program it in arduino so that i can turn on or off each segment to display a countdown for 24 seconds! big thanks!
similar to this picture but only two digit display countdown timer for 24 seconds
One way would be to know which led indexes map to each segment (btw, don’t you have 4 per seg, not 5?). Looking at your wiring, 0-3 looks to be the middle horizontal, 4-7 the upper right vertical, 8-11 would the top, etc.
You could store those values in some sort of mapping array or create a function to match it up. For each number, you’d know which segments need to be turned on (7 would be the top, and right verticals for example). If you wanted to flash a 7, perhaps it would contain the id of each segment, and then you could iterate through the LED indices matching those segments to turn on {4, 5, 6, 7, 8, 9, 10, 11, 24, 25, 26, 27}.
I’m pretty new to mapping and thinking about matching up a desired shape to a series of LEDs, but that was what came to me.
@Joem_Deocampo , I took a stab at this. I believe this will work, but I don’t have a 7 segment layout setup to test with so let us know after you build yours! I used the same sort of wiring layout as you posted.
This code allows you to easily vary the number of Pixels Per Segment with a variable in the code. Just make sure your NUM_LEDS is either equal to or greater then the total number of pixels in your two digits. NUM_LEDS could be a much larger number and you could do other stuff with the rest of the pixels and the two digit display would only be the start of a larger string.
@marmil woooah! this is great! i will now have my main guide for coding the led strip. can this code be applicable to sk6812 led strips? these are also individually addressable. i will let you know if my thesis project will be successful. Millions of thanks to you sir! and i’m trying to have a countdown project. how can i reverse it. from 24 to 0 number digit. a shot clock.?
@marmil Good day sir! I tried your codes in my sk6812 led strip. I tried to change the color to red but it didn’t work. Is the color order the same for APA102 and SK6812? Big thanks sir for the help! missing/deleted image from Google+
You’ve set CHSV segON(0,0,255); which is the color red, but saturation 0, so it’s going to be white. Set saturation to 255 and you will have red.
When using HSV, you define the hue of the color (that is, where it is on the color wheel), how saturated it is, and how bright it is. Read this page if you’re not familiar with setting colors with HSV.
@marmil Good day sir! can i ask for help? how will i stop the loop? using button? and i wish to have the digits to change color from red to blue to green using a single button also. i wish also to have a button for a reset countdown? a button to have a 15 sec countdown? there will be 3 buttons. 1 for start/stop button, 1 change color Red-Green-Blue button, 1 15 sec button? how will i insert this functions to your given code sir? Big thanks sir :))))
Break your project down into parts and work on each separately. When you verify each is working then you can work on combining them into a single program.
Use the serial monitor to print out variables to see what’s happening and verify the code is doing what you expect.
@marmil i really appreciate your help sir! big thanks! by the way if i’ll implement a connection via wifi, one arduino for the controller and another arduino for the led strip, is this similar codes that i’ll use? because i’ll be using button in the controller then command will be sent via wifi to the led strip? how will i start doing that sir? i have esp8266 based wifishield. many thanks! heheh sorry for the inconvenience sir i have very poor knowledge in programming hoping that you can understand my shallow questions hehe
Yes, you can do what you describe. But I highly recommend that you work it out without the WIFI part first on just a single controller. Start simple! After that you can work toward the final idea (which does sound cool).
Figure out how to have your controller recognize button presses and have it “send a command” to the serial monitor for testing.
Then work on having those commands actually change what the LEDs are doing with if…else statements and/or the use of switch case. After you get that working some of that code (that part that receives a command and changes what the LEDs are doing) will get moved to the receiver.
this is great sir! thnx @marmil sir i tried the codes on the led strip, it seems that it doesn’t fit the count. i tried to record it. The led strip counts from 0 to 24 sir but in the video it took only 22 seconds. how will adjust it so i can synchronize the count? thank you sir