I am having some troubles. I have a robot I am working on and I am programming some emotes into him to get a sense of personality. I have some LEDs on him and I want to trigger individual ones in a timer pattern. Think of it like a small animation. Its is not random, and it cannot have give or leeway. Each LED needs to go on at the exact time I tell it to go on and off.
I have attempted many things to do this with no success. Showing you my code would be useless at this point.
I am more asking for ideas on how to approach this.
I have all of the elements working. I am able to reliably get the exact time when they have to start. And I know how to call to each one individually. Just need to figure out how to animate this sequence in code.
Mostly been working with UniversalTimer.h and if statements. But its not precise enough.
Mostly been working with UniversalTimer.h and if statements. But its not precise enough.
Use that to set a benchmark value for the millis timer and then just use that to actually see when to light up the sequence. Note all your code has to be written as a state machine.
Thanks for the info. Let me add some extra info and clarify a little.
I already have the LEDs working. I am able to do things like a timed blink with them and I know how to turn on each one individually.
I am using WS2812B LED Chips and have a string of 11 of them together. They are controlled by an Arduino Uno and I am using Adafruit_NeoPixel library to control them. I don't have any hardware issues or software issues.
I am able to do basically 95% of my project with the setup I currently have. I don't want to change any hardware or add any more libraries if I can avoid it. I just wanna figure out how to do a simple sequence of blinks with the LEDs. Basically I am looking for ideas on how to write the code because I am not a coder by trade. I am only just dabbling in it for small projects like this.
Without seeing code that demonstrates what you have tried and why it does not work, it is difficult to suggest what you should do.
Grumpy Mike has already said it will need to be written as a state machine Finite State Machine Programming Basics – Part 1 – Arduino++, so maybe this will help, but there are lots of other resources for how you can do this, you will need to search. The examples I suggested earlier are all based on finite state programming.