Help with LED Lamp concept.

Skorn:
(strykeroz, I'll back out of this discussion to avoid creating any confusion.)

Please don't. There's always multiple ways to skin a cat in code :slight_smile:

strykeroz:

Skorn:
(strykeroz, I'll back out of this discussion to avoid creating any confusion.)

Please don't. There's always multiple ways to skin a cat in code :slight_smile:

I also ask that you keep adding your input, every little bit helps.

I am getting to the point where I feel that Arduino Programming is not for me. I have been playing with the Arduino for almost 3 months and I am not as far a long as I would like to be. Not that I have not been trying.

I put a side at a minimum 2hr (More on the weekend) each night to mess with the Arduion. I Search the Web, watch YouTube and read this forum a long with a few others. I picked up a few books a long the way. But nothing helps me as much as the input I get from this Forum and it members. So please keep the post coming.

But guys I do ask one thing. I am nowhere on the same level as you all and some of the things that are said go over my head.

So to Fungus, Skorn and Strykeroz

Learning to code is something that needs proper study, not just hacking around.

If you're serious about Arduino you're going to have to read some non-Arduino coding tutorials.

kculm,

Working with the Arduino and electronics gets pretty frustrating for anyone at times. Patience is the key and 3 months is really not alot of time when you are coming in with little electronics and programming knowledge and experience.

I was going to suggest that you take a step back. The code you are using for your traverse routine was developed by someone else and it is fairly advanced for a beginner. I suggest "shelving" that part of the code and come back to it down the road when you can understand it better. Refocus your effort on developing your own code to control the LEDs in a simpler fashion, such as blinking and pulsing the leds.

I agree with fungus that its essential to spend some time studying general programming in any language. C or C++ is probably your best bet to learn the Ardiuno...

fungus:
Learning to code is something that needs proper study, not just hacking around.

If you're serious about Arduino you're going to have to read some non-Arduino coding tutorials.

I am very serious, Can you recommend something.

Thanks

Skorn:
I agree with fungus that its essential to spend some time studying general programming in any language. C or C++ is probably your best bet to learn the Ardiuno...

Skorn,

I totally agree with both of you, the code I am using is way above my Pay grade. But its the only code I could find that does what I need it to do. (nice And Smooth).

Like have said I am making a custom acrylic lamp. So far I have spent over 200 on custom cut and polished Acrylic and the last part of the puzzle is the code.

I will be sure to post a pic/video once it is done.

Now that being said. I have done all the examples I could find on how to make LED’s blink, fade, and all the rest. But most of the stuff I find show you how to do them and not why. Another reason I picked the code I am using is because I knew it would be a challenge. Just did not know how big of a challenge it would turn out to be.

I am going to take your advice and look in to C or C++ , I have played with C# in the past but just for fun.

Also if any of you know of good books or sites please let me know.

I am going to go back over the posts and see what I can figure out from all the input.

Thanks Guys.

Are you trying to do anything like what I posted?

http://arduino.cc/forum/index.php/topic,152268.0.html

Hi,

I don't want to discourage you and understand that you've commited alot of time, effort and expense to see your project through. But the fact is, your example code does impliment bitmath, vectors and other methods that some may argue are overkill for controlling a small number of LEDs. Furthermore, bitmath is usually pretty difficult for most beginners to grasp. Bitmath has sent many students home packing... :slight_smile:

I did a quick look on the NET for a simpler project for you to consider. You could still impliment a button to switch to different modes, one of which is color fading.
http://elenamuse.wordpress.com/2012/11/06/rgb-mood-light-arduino-project/

As for recommending books and such, I believe its up to the person to decide what they want to learn and study. There is a vast section on education in these forums you look at and ask at, start from there. Its also tough for us to offer suggestions as we really don't know what your level of understanding on this subject matter is. If it's as low as you say, then pretty much and any beginners level material is good.

Skorn:
As for recommending books and such, I believe its up to the person to decide what they want to learn and study. There is a vast section on education in these forums you look at and ask at, start from there. Its also tough for us to offer suggestions as we really don't know what your level of understanding on this subject matter is. If it's as low as you say, then pretty much and any beginners level material is good.

As always thanks for your input. I have been doing a little research on what path I should take as far as learning a program language and I hit a snag.

I know that the Arduino is based of the C (or is it C++ Language) so my question is this.

Should I start with learning C and then move on to C++. Or, should I start with C++ and not do C.

Aslo, I have not looked at the link you sent, I will when I get home tonight. But I wanted to say thanks for posting it.

I would recommend learning C then C++ as an easier path, but that is just how I came to know the languages. I don't try and write any C++ features in my code but of course use most of the arduino libraries that do use C++ features. As the name implies C++ built on top of the C language (C plus stuff) so most all of C functions and statements work in a arduino sketch.

Lefty

Skorn:
As for recommending books and such, I believe its up to the person to decide what they want to learn and study.

It's very difficult to recommend books because everybody learns in a different way. This is especially true for complex subjects like programming.

Also, I haven't read any 'beginner' books since the 1980s and I'm sure there must be some newer ones published since then.

kculm:
Should I start with learning C and then move on to C++. Or, should I start with C++ and not do C.

On a desktop machine I'd say NO in the biggest font available. In C++ you want to be using STL, smart pointers, RAII, etc., so that memory management is automatic and you never have any of the problems that C is famous for.

On the Arduino, though, you shouldn't really be doing ANY of those things. Arduino coding needs a careful selection of the appropriate features of C++ and I doubt there's a book that does this.

(Actually, all C++ coding needs a careful selection of the features of C++...there's some things you should never use)

None of this is helpful, I know.

At the end of the day I'm still going to say "don't learn C, learn C++". If you learn C first you'll pick up some bad habits that might need to be unlearned later. Missing out C++'s 'classes' in particular would be a bad move. Concentrate on things like syntax, program flow, basic data types (int, long, etc.). Ignore anything that uses "dynamic sizes".

Also look for stuff on how CPUs work. Getting a clear picture in your head of what bits and bytes are, what RAM is, how CPUs do their thing is very important.

retrolefty:
I would recommend learning C then C++ as an easier path, but that is just how I came to know the languages. I don't try and write any C++ features in my code but of course use most of the arduino libraries that do use C++ features.

Learning a few C++ features and using them can make many coding jobs far neater/easier/safer.

eg. An RGB LED. If you've got several of them attached it makes far more sense to create a LED 'object':

class RGB_LED {
  byte reg,green,blue;
  void setBrightness(byte b) {
  }
  void setHue(int h) {
    // Set the color using a 'hue' value...
  }
  ...etc.
};

// Then you can have lists of them

RGB_LED frontLeds[8];  // 8 RGB leds at the front
RGB_LED rearLeds[8];   // 8 RGB leds at the rear

How would you write that in C?

byte frontLeds[8][3];  // 8 RGB leds at the front

void setHue(byte led[], int h)
{
  //  .. ?
}

Surely that sort of pointer manipulation isn't something we should encourage when you're using a C++ compiler.

Surely that sort of pointer manipulation isn't something we should encourage when you're using a C++ compiler.

I'm sure your right. It's just I don't 'think' in C++ so don't even consider how to perform a given task using non C features. I realize I'm using C++ features when I use the serial library functions but that's not the same as building such functions from scratch. I usually find a way to accomplish what I'm trying to do sticking with C and as I code for my personal retirement hobby only it's not a restriction that I feel.

Digital and analog electronics hardware is where my past employment experience and education was grounded in, software is just the BS I have to put up with to get stuff working like I want. :wink:

Lefty

Hi,

fungus' original recomendation was you learn some general coding. You should be advised that the question you've asked is a really tough one to answer, likely to recieve alot of varied feedback. I agree with Retrolefty's suggestion with some caveats. C is probably better to learn first if you will just be programming the arduino. If you wanted to write programs for other things, like computers or phones etc. it's arguably not the best option.

Learning C first is fine as long as you understand that switching to C++ down the road will require that you change the way "you think about designing making your programs work." Which can be really tough for some people as it imposes a bunch of new rules that are hard to make sense of at first... These new rules tend to make it a more powerful language because you can manage Complex programs easier and thus is more productive. So if you do end up learning C first, always keep that in mind and don't forget it. You may want to do a bit of research on the differences between the languages and their "programming paradyms", then make a decision. One final thought to consider- today, many microcontrollers like the arduino are still generally limited by its resources which is why C is so widely used. In the coming years as the MCUs continue to evolve you may see a greater shift to Object Oriented design. Again, these are just my personal opinions and recommendations.

Skorn:
Learning C first is fine as long as you understand that switching to C++ down the road will require that you change the way "you think about designing making your programs work."

Yep. That's why I think it's better to learn C++ first.

C++ has a lot of little, non-obvious advantages that add up to quite a lot. Classes+objects in particular.

Oh my head hurts. lol

No really thanks for all the input. I found a course on lynda.com the goes over both just to get you started.

I am going to look over it and see. As far as my plans for programming, well its only for the Arduino. I am Network engineer and IT manager, I have no plans on
Becoming a programmer. This is all just for fun.

I may go over the code I have now and see I can dumb it down so I can finish my Lamp though

kculm:
Oh my head hurts. lol

No really thanks for all the input. I found a course on lynda.com the goes over both just to get you started.

I am going to look over it and see. As far as my plans for programming, well its only for the Arduino. I am Network engineer and IT manager, I have no plans on
Becoming a programmer. This is all just for fun.

I may go over the code I have now and see I can dumb it down so I can finish my Lamp though

Well to continue on the thought, do realize that C is a proper subset of C++ so you are not having to 'switch' to anything or 'unlearn' anything to after mastering C to start learning and utilizing the features that C++ adds to the language.

Lefty

Hi Lefty,

Well to continue on the thought, do realize that C is a proper subset of C++ so you are not having to 'switch' to anything or 'unlearn' anything to after mastering C to start learning and utilizing the features that C++ adds to the language.

I'm going have to strongly disagree with that statement. I know when I personally had to make that Paradym Shift it was extremely difficult, and it was for many other programmers too. I only bring this up as I don't want someone who has asked us for help to be potentially misled by trivializing the difficulty in the "switch" for some people.

One of the well known books I read to begin learning C++ explains the challenges here:

Skorn:

Well to continue on the thought, do realize that C is a proper subset of C++ so you are not having to 'switch' to anything or 'unlearn' anything to after mastering C to start learning and utilizing the features that C++ adds to the language.

I'm going have to strongly disagree with that statement.

Me too. It's a common belief among C programmers but it's not really true.

C++ isn't "C with extra stuff" when that "extra stuff" makes up 90% of the program.