ESP32 and FastLED Library

Presumably FastLED uses a zero-based referencing method for the LEDS, so if you have 30 LEDS then these are referenced as 0-29.

Pete.

Okay but since I am dictating the limit maximum count for the for loop I don’t understand how this will affect the outcome?
This is what I did:

 for(int n=0;n<=29;n++){
     Serial.print("Value of leds n=");
     Serial.println(n);
     leds[n]=CRGB(r1,g1,b1);                            
     FastLED.show();
  }

which works without crashing then i do this and it crashes:

 for(int n=0;n<=30;n++){
     Serial.print("Value of leds n=");
     Serial.println(n);
     leds[n]=CRGB(r1,g1,b1);                            
     FastLED.show();
  }

Yes, because this allows n to reach a point where it is equal to 30, which is the 31st LED in a zero-based referencing system.

Pete.

Okay thanks Pete, I follow. It was not a problem when using the Arduino boards so I didnt even realize :sweat_smile:.

Maybe the ESP32 Core is less tolerant of out of bounds addressing than the standard Arduino core.
Or, maybe your code or the value you used for the number of LEDs was slightly different?

Pete.

This is a very basic knowledge of programming (yet creating very dangerous results) you have to master before moving forward. Or there will be more and more crashes and headaches.

To pinpoint exactly where it is in a many thousand lines of code requires a special Crash/Exception Decoder.

That’s why I said Hope you re-study the code and find out why yourself and haven’t said anything until you at least understand.

But it seems that you still haven’t accepted and just wasted @PeteKnight precious time.

1 Like

You are absolutely right, the ESP32 is probably less tolerant than the arduino boards. Thanks Pete

Thanks for the feedback and and advice @khoih.

When i re-looked at the code on your suggestion i saw another error that I has made, rectified it and assumed that is what you were referring too :sweat:

Its not that I didn’t accept it, i was trying to understand where and what about it was erroneous. After experimenting and with Pete’s guidance I finally realized what you were hinting at. This is something that I should have realised because it is something that I knew but overlooked since it didn’t pose an issue with the arduino boards. I was also tackling errors elsewhere in my code that were non issues with the arduino boards in conjunction with dealing with this one so it was easily over looked. That is a fault on my fault on my part, for not realizing sooner.
While I appreciate your help khoih, your tone in this message sounds a bit demeaning. The reason we seek assistance from forums is to get guidance from those more experienced than us or who are able to notice errors we may have overlooked.

I am sorry @PeteKnight if you feel as though I have wasted your time, but let me assure you it was not a waste of time for me. I was able to get a large amount of my code working thanks to you and others. Thank you for both your time and your help.

Well, the good think is that you’ve identified and fixed the issues and learned sone stuff along the way.

Unfortunately, the forum tends to attract a lot of people who have either no programming experience or very limited experience. Some of these just want people to write their code for them, and in many cases the projects are being developed for school or college projects, rather than because the person really wanted to solve a real world problem.
Of course, some of these people will ‘get the bug’ (okay, that’s maybe not the best of phrases in the current situation :frowning:) and go on to have a long and rewarding relationship with MCUs and Blynk.
Others are just time wasters, but it’s difficult to tell which is which.

As a result, the more experienced members of the forum tend to give a few hints to point them in the right direction, or to point-out issues without actually writing their code for them - so that they learn by working part of the problem out for themselves rather than simply copying code without understanding the solution.

Obviously you are more advanced than the users in this scenario, but probably started by ‘playing’ and building your skills.
Forum members in this category are often pushing their own skill boundaries, or have gotten bogged-down in a ‘can’t see the wood for the trees’ situation. Here, it’s usually just a case of pointing the person in the right direction or having a fresh set of eyes to spot the mistakes. For this group of people it’s often just a case of suggesting a different code structure, or pointing-out a coding error and letting them get on with it.

The bigger problem is that if you have had no formal software development tuition then it’s difficult to make the transition from a ‘code tinkerer’ to someone who takes a structured approach to development.
When I was taught to program computer time was limited, so you did your code structure development, coding and testing on paper, then when it was your turn you say at the terminal and typed your code in and attempted to compile it. If you had less than a thousand fatal errors in a 50 line program then you were doing well, and 950 of these errors would be caused by a missing comma in line two.

This background gives me a different approach to software development and debugging, and I think that’s what @khoih was hinting at when he said…

Once again, I apologise if I’m mis-speaking on @khoih’s behalf.

My advice would be to build on what you’ve learned from this exercise, especially as far as debugging is concerned. I would also add more in-code documentation, as this helps focus your thoughts as well as making life easier in future.
Using tabs within the Arduino IDE can also help structure your code better, but I still like to sketch-out program structure and flow on paper before starting to write the code.

Hope this helps.

Pete.

2 Likes

There is an exception decoder for the ESP32 available, for use within the ESP32 / Arduino IDE, this can help to narrow down the cause of crashes. I agree completely with what Peter and Khoih say. Far too often people take disparate pieces of code gleaned from the internet and try and patch them together to form a coherent application. It doesn’t work unless people have a thorough understanding of each code segment and how it interacts!

2 Likes

Hi @Alli

I’m sorry if you think the comment as demeaning. But being one of the old timers, I believe sometimes we have to be strict, hard, straightforward, and not politically correct to be efficient and really helpful.

As we all know you’re a more sophisticated members, the helping approach is very different: hinting and letting you to research and solve the problem yourself. Hoping you’ll be actively learning and acquiring much better skills than just being passively using the code.

I also saw you went to the wrong assumption that this line of code functions perfectly on the arduino controllers will be OK to use. That is a dangerous time bomb waiting to explode at the time you’re least expected. That’s why I decided to intervene.

You must see the real error, correct then learn a hard lesson from any mistake before it’s too late to spread into other more serious projects. This might be the most precious lesson we, the old timers, have learnt throughout our lives.

In this forum, we’re working of our own free will, and are not interested in demeaning and attacking anybody. Just try doing the the best to help each other, as we have been helped and learning from this forum. Certainly, we also expect other forum members to be nice to each other, at least not ignoring the help by testing and thinking the proposed solution, or we have the better choice to ignore.

1 Like