animation of 4 LEDs

Hello,
I am totally new to arduino and this is my very first project.
I got into arduino because I had this idea and then I searched the internet how to realise it and it directed me to microcontrollers. I have started from zero, learned first the ohms law to understand the difference in between volt, watt, ampere and all that. You know, I really really started from zero and am still not so far into it. Internet is what I use as learning resource, mainly youtube.

I am sorry if my question is in the wrong place (should I put it into the LED forum?).

I would like to animate 4 LEDs seperately, but in I will have 8 total (I want a pair to always do the same thing). I have bought WS2812b RGB LEDs.

I dream to animate those 4 LEDs in a way that they give a very organic biological output. I would like them to have some sort of conversation.

I picture them to maybe sometimes "chatter" all differently, sometimes they agree and do the same thing. Maybe LED1 starts with dimming sequence (like a mac book sleeping light) and in let`s say green, and the other 3 still chatter in each their own brightness and colour, but slowly they all tune in to LED1 and join the same dimming sequence rythm and same green colour and "agree" in this conversation. Then maybe a dramatic pause and they are all off. And suddenly they all dim up to be really bright and give a purple until each once again breaks away and kind of does their own thing, both in brightness and colour.
Or maybe I would like a gradient colourchange across them, LED1 starts in a red, LED2 takes that red and fades it to purple /while LED 1 just dims down to off), LED3 fades the purple to blue (while led2 dims down to off) and so on.
Just to give you an idea what I dream to achieve.

I would like to achieve a 1-2minute lightshow this way until it loops.

I have had a very quick and superficial search for projects using the fastled library. I wanted to see if anybody already did what I want to do. But so far I did not find any project that does what I dream to do.
What I see is rythmical blinking in varies ways. I have seen gradient colour change which is one of the things I would like to do.

But I haven`t yet found a project that animates LEDs to give that kind of organic biological output that feels as if they were having a conversation. I would like to ask for help how to achieve this. Maybe someone could point me into the right direction what to read about and what to play with?

Because I start to be afraid that I have to write the code manually for 4 LEDs for 1 minute to achieve this kind of biological feel output?

I am not so 100% sure I understood this correctly, but 60 hertz is like the minimum you need to fool the human eyesight to think the LED is consistent. Right? so that would break down into 16ms for each time unit, and how many of the 16ms are on or off depends on the dimming sequence (getting brighter or getting darker.) Right? So it maybe would make sense to have 16ms as one time unit?

So in addition to that dimming I would have 3 colour values at any given point in time, that`s like 5 values for each LED for any given point in time. That is not easy to keep track off.

Is there maybe a graphic interface that would allow me to play with my leds and design this show, that shows me a table with those 5 values and a time line? And that would be kind of interactive so that I could play and see what actually looks good on the project? And maybe even keep track of the 5 values of each led?

I am really sorry if my questions are stupid. This is really my very first project ever and my very first time looking at any sort of code. Learning that my phone actually blinks and isn`t consistently on as I thought it was rocked my world. Learning about binary rocked my world view, too. Suddenly I understand why my phone has 32GB storage and not 37 and I understand all these reoccuring numbers in every day life.
So I am really a beginner. But motivated.

It would be very awesome indeed if someone could point me into the right direction, what to read and work on, what to look up and learn.

Thank you very much!

Don’t look for code, starting writing it!!

Start being able to flash one led, then two and so on. There are examples in the IDE, play with those.

Then look at PWM
as a way to dim leds

uhm... dude...

I kind of have to learn code first, dont you agree? I dont wake up one beautiful morning and speak Hindi or Mandarine either. Also for that I would need learning resources and maybe someone who points me into the right direction and a dictionary. I can`t just write code, dude.

I looked at the blink an led and the dimming an led examples in the IDE.

But I cant help but think there must be ways in code that I still dont know and will never know unless someone points me to the concept by giving me the right key words to look up.

To look for code you also have to be able to understand what it's doing as you'll always have to adept it to your needs. So yes, start learning to code if you don't know to yet.

FastLED library is indeed a great way to control the WS2812B LEDs. No need for PWM or other fancy controls, you need one pin to rule them all.

1.) I wouldnt even bother or think about yoru specific led 'animations/patterns' until you get familiar with Arduino itself (and all the naming conventions used with it).. so that you can actually understand any advice that is given to you.

** maybe start with the Adafruit Neopixel tutorial(s)? understand how its all wired, the pros/cons.. powering issues..etc

Their tutorials is basically exactly what you want.. but in the end you'll change out their default patterns/animations for ones of your own.

All that being said.. Neopixels come with some stiff requirements, that might not be too easy to grasp or workaround for newbies.

That only update as a specific rate (so I hope you dont want to do any POV stuff)..
They also have very specific timing...

So any of your other actions (button presses..etc) are not missed because the Arduino is too busy with the Neopixel 'stuff'..

Your animations/patterns will also have to be coded in a way so they are (what is commonly referred to as) 'non-blocking'..

Meaning.. you can be stuck in some led animation/pattern routine.. where any buttons presses or sensor checking never gets addressed (or missed) because you stuck in some pattern updating loop.

You might want to look into using DotStars instead.. almost exactly the same (more wires to communicate to them).. but all individually addressable leds... like Neopixels.. same code can (more or less) be used. They just dont need to be constantly updated..

uhm... dude...

I kind of have to learn code first, don`t you agree?

We all agree.

The web features lots of C/C++ coding tutorial sites for beginners to advanced coders. Take advantage of them.

The Arduino comes with lots of simple examples that teach you how to use the special features of the Arduino and to interface with hardware, like LEDs, sensors, other computers, the web etc. Take advantage of them.

Step by step.

hello.

Perfect. loads of keywords to look up. thank you.

Unfortunately the internet works this way. You need to know what things are called to be able to search for them and take advantage of what you find.

I cannot change my LEDs, it is ws2812b thingy leds with four legs and classic halfdome shape, it is that shape that is crucial (cause I am heatshrinking optical fibre to it and those square flat ones offer no physical hold to do so.) I didn`t find any other half dome adressable LEDs.
Also, they are already bought.

So I gotta learn how to deal with what I have. And thanks to you offering me keywords I can now start the journey of googling and learning. And nope, no POV stuff. Just making fibre optic end points glow. But there will be a light sensor used as a threshold. darker than x and it gets turned on, lighter than x and nope. I got that part to function already with if then else.

Please do keep it coming. Those keywords are like light houses that offer some guidance what to read and learn to make this project happen.

Because so far on this journey I learned that code is not the only thing I need to know. I also need to know how things function inside the microcontroller to actually understand what the code does. Like, it was good to understand how an analog output of a lightsensor with mathematical infinite values gets kind of compacted to fit the 10-bit counter. Stuff that probably everybody else knows and I dont. And then there is the lingo that I dont understand yet, so when someone mentions capacitor I have to go and learn what a capacitor does. So it is a quite a huge project for me actually. And without keywords to look up I am lost on the way and stuck.

So it is a quite a huge project for me actually.

A major first step is to recognize that, so congratulations! Lots of beginners don't and immediately get frustrated when they copy something from the web and "it doesn't work".

This excellent Blink without Delay tutorial is really, really important for "real time" programming, so study it carefully.

One of the very best and clearest sites discussing standard Arduino internal hardware (input/output, ADC, timers, serial data transmission, etc.) is Nick Gammon's.

How many LEDs are you planning For?
Initially start your develop with a few - maybe 20 in a string...

That will give you enough to do so that your code has to accommodate ‘more than 8/16.... then if the number grows later, you’ll also have to consider how you’re going to power the long string(s) of LEDs.
This what most experienced developers would do.

Once you have the basics blinking, you’ll probably need to learn about array[]s, and NOT using the delay() function...

Happy hunting.

lastchancename:
How many LEDs are you planning For?
Initially start your develop with a few - maybe 20 in a string...

4 LEDs, as in title. In reality 8, but a pair is supposed to always do the same, so 4.

jremington:
A major first step is to recognize that, so congratulations! Lots of beginners don't and immediately get frustrated when they copy something from the web and "it doesn't work".

I recognise this a shitload of stuff to put into my head but that doesnt help with frustration. Hence the question what exactly (out of this gigantic field) I need to look for. And as I then read about it and they mention things and concepts I dont know I need to look that up, too. But it is hard to judge if I get sidetracked or not. And I know by now that I could spend years with this technique of collecting dots of information and hoping that lines that connect those dots one day become visible.
But frustration- yup.

I kind of also desire to actually have this project working and running in overseeable future. Human need for gratification.

6t6t6t:
I cannot change my LEDs, [...] they are already bought.

That's one of the worst arguments. One thing you ALWAYS have to be open to in this world is to switch to a different piece of hardware (most such parts are very cheap anyway). The unused parts just become part of your collection of unused parts, a collection that comes in handy very often, as you get new projects to build.

In this case I do think ws2812b are an excellent choice, as they're so easy to work with. The hard part of this project is no doubt the algorithm your LEDs work with.

A possible way to implement this:

  • figure out how you want an LED is to react to the other LED's parameters, and what those parameters can be: blinking, fading, colouring come to mind. E.g. if another LED is green, and I am red, I want to add a bit more green and a bit less red. Or: I want to start fading towards the other colour, adding a bit of fade speed until I reach the other colour, resulting in an overshoot as we approach one another (the other LED will likewise want to fade from red to green).
  • give each LED a starting point.
  • every time the algorithm runs, the LED adapts its parameters to the parameters of the other LEDs.
    You could even add a factor to how strong an LED reacts to the others: e.g. a stronger reaction to the direct neighbours, lesser to a further away one.

Lots of programming work, not easy to implement on paper, let alone in actual code.

6t6t6t:
I kind of also desire to actually have this project working and running in overseeable future. Human need for gratification.

That's a giveaway...
Be prepared to 'give up' several times... until your subconscious tells you to "get back on the bike"
The secret to success - is if that failure nakes you lose sleep - and get back to the computer every day & night for a week - trying to nail that challenging concept.

You learn one trick, and it seems like the rest is going to be a breeze. Happy Days.
In fact you've just crossed the first threshold. Tomorrow you'll start to realise 'what you don't know'.

  • Unconscious | Incompetence
  • Conscious Incompetence
  • Conscious <|> Competence
  • Unconscious Competence

| -- YOU ARE HERE
Steps 3-4 form an infinite loop!
<|> Most hobbyists are happy to be 'here'

The good (bad) news is that once you "know everything" - you'll discover a new language / processor or other important piece for your next project! And you'll start growing a parts bin from failed atttempts!

[quote author=lastchancename link=msg=4218752 date=1561182865The good (bad) news is that once you "know everything" - you'll discover a new language / processor or other important piece for your next project! And you'll start growing a parts bin from failed atttempts![/quote]

LOL that is so true :slight_smile:

wvmarle:
The hard part of this project is no doubt the algorithm your LEDs work with.

Lots of programming work, not easy to implement on paper, let alone in actual code.

My learning is not homogenous because I cannot see another way but to collect dots of information, hoping it will make sense later.

I still cannot code. I can look at some code and kind of understand what they are doing.
I took the sensor code from adafruit, but there are two lines that I guess deal with the logarithm nature of my sensor. I tried to learn what is a logarythm, in the mathmatical sense, hoping it then would make more sense. But failed. I don`t understand it.

I googled "if then" and was delighted it actually exists as code. Was my idea, but yay, it exists. I then tried out where to put it into the adafruit piece of code, what the compiler would take and would make work.
It works now. No idea if it is correct.

I was utterly surprised that the microcontroller didn`t turn the light off again by itself when the condition under which the LED is supposed to turn on falls away. Like, I thought it would be self explanatory that when I say "light up LED if sensor output is smaller than x" that the light gets turned off again next time around the loop comes to that part but the sensor value is bigger than x. Alas nope, I had to google the "else". Now it works.

For my LEDs...
I have not yet made it change colour at all.

I don`t know, but I guess that human eyesight is tricky. I would like to play and see what my eyes perceive and how it will look. I had hoped to find a more intuitive way. A way that I can play with my leds and learn what saturation and what brightness is pleasurable to look at and works esthetically on my actual project. A way that allows me to play without changing every detail in the code every time I want to see what happens if.

And I wish it was school or something where they give you a pensum sheet and you know that whatever you might need is on that sheet.

And maybe I should simplify and be happy and call it a day if I can achieve gradual colour change in whatever rythm. There must be a reason why all led projects I came across on the internet are happy with rythmically blinking leds, even though it is not so pretty.

RGB was new to me. One webpage talked about HSV rather than RGB because you can change only saturation or only brightness and I think that sounds a lot more applicable.
But then another webpage said that arduino needs it in rgb and that I need to somehow convert HSV back to RGB. I need to read more about it. I still don`t understand it fully.

Stop.
Go back and go into the IDE examples one step at a time.
You’ll learn some bad habits - but as you grow, you’ll cast those aside to perform new, better tricks.

Programming and building in any environment REQUIRES a basic understanding of logic, physics and time to create reliable outcomes.

As others have said elsewhere- it may work right now - most of the time, but would you bet your life on it?

6t6t6t:
I was utterly surprised that the microcontroller didn`t turn the light off again by itself when the condition under which the LED is supposed to turn on falls away. Like, I thought it would be self explanatory that when I say "light up LED if sensor output is smaller than x" that the light gets turned off again next time around the loop comes to that part but the sensor value is bigger than x. Alas nope, I had to google the "else". Now it works.

Well, of course. A computer doesn't do anything unless explicitly told so.

Apparently you had a condition under which to switch on the LED, but forgot to add the condition under which to switch it off. Without telling the computer to switch off something, it will never happen.

FastLED has done a lot of testing to make the colours and brightnesses follow human perception. Don't worry too much about that. Start by getting the built-in LED to blink.

The problem is you are looking for short cuts , something quick to make it work, something you can grab from elsewhere that will do the job . It’s not the way- spend some learning time on it , play with the IDE examples , learn some basic coding , have fun.

This comes up a lot on this forum - the Arduino is about learning electronics, learning how to code to make stuff , there are no real shortcuts that don’t end up in disappointment , frustration , giving up. You just have to put the hours in or take up a different hobby , something easier...

hammy:
The problem is you are looking for short cuts , something quick to make it work, something you can grab from elsewhere that will do the job . It’s not the way- spend some learning time on it , play with the IDE examples , learn some basic coding , have fun.

This comes up a lot on this forum - the Arduino is about learning electronics, learning how to code to make stuff , there are no real shortcuts that don’t end up in disappointment , frustration , giving up. You just have to put the hours in or take up a different hobby , something easier...

I understand that you probably have seen many people come here and ask more or less stupid questions and that it is easy to sort people into categories.

It is entirely up to you what you think of me, you are entitled to your opinion about me.

I do not see myself as such. I have my opinion about myself and I am entitled to it.

I know I have spent weeks already catching up with physics I never had at school. Trying to make sense of tech specs with zero prior knowledge, googling fucking everything. Reading about components. Trying to understand wtf is happening inside a microcontroller. Trying to understand what this quartz thingy does inside. Trying to understand concepts of maths that I equally did not learn at school- and failing. I still dont understand what is a logarithm because I cant make sense of mathmatical equasions. I have zero physics education, sucked badly at maths, I have no clue about computers, I have hitherto not even heard about binary other than in movies and pop culture referances. And step by step I am catching up- slowly and not fully because it is not so easy to find explanations that I can make sense of, lacking education.
I know this way is long and exhausting.
I also know I am human and so is frustration and loss of motivation- if there is not sometimes a little carrot on a stick to run after. Or unless you can see a little glow of light at the end of the tunnel.

I also know that this whole field is gigantic, that it is easy to get sidetracked with stuff that is not relevant to my project right now. That doesn`t mean it is not worth learning that stuff. But it means that it can wait for another project.
It is also human to define 1 fucking goal and try to go after it. and for me right now it is animating 4 LEDs and understanding every part involved in the process.

and if I ask here in this forum about what is relevant and how I could do what I decided to set out to do, then it is not because I want a short cut. It is to get the right keywords to google and learn, to know what is relevant for this project here and now so that I can achieve my goal.

thank you.

(also, there were shortcuts had I wanted them. There are loads and loads of cheap preprogrammed plug and play LED applications. There is absolutely no need to pay more money for board and components and to go through the trouble of animating them yourself unless you wanna learn how.)

6t6t6t:
It is also human to define 1 fucking goal and try to go after it. and for me right now it is animating 4 LEDs

Getting that done is not too hard.

and understanding every part involved in the process.

It sounds like you have to continue your learning for another year or two. Yes, I'm serious. You're not going to squeeze what a student spends several years on at school into just a few weeks. As you say yourself the field is huge, and there's a lot to be learnt.

You can, however, give yourself a pretty good start by first going through the examples the Arduino IDE has included, and the examples given by the FastLED library, and a C++ tutorial or two for every single line of code that you don't yet understand.

6f6t6t...
Your goal and approach - and patience are good.
There is only so much you can learn in a given time - on your own.

I’ve suggested to many ‘starters’ here ( I really don’t like the term ‘newbie’ )... they need to find a flesh-and-blood ‘buddy that can push them over each speed bump.

That could take the form of classes, but to reach a specific goal in minimum time, a competent friend, one-on-one is the only way I’ve seen that gets there relatively faster.

You’re on the road, now find someone to follow, not a map!