I started programming back in the early 1970's with Basic. I am not a great programmer but in Basic I can pretty much kind of get the job done. I am aware of modern programming ideas (years ago I did a little home programming in Pascal) like subroutines, reusable code, etc. but C++ seems terrible limiting in its structure for doing the programing easily . There are no subroutine calls. Labels seem to be not doable (no real goto statement... I know that is a no-no). And the Ardunio compiler is very poorly documented as to the required structure.
I got my program to compile but I am not ready for testing as some of the hardware is still in the mail to me. What is missing is a cookbook on the structure of C++ with complete programming templates. Examples don't do it! A list of variable types, functions, etc, is not a guide to making a program. Most of the examples vary in implementation enough to lead to confusion (at least for me). So here was my approach, right or wrong, you tell me.
The main program is in a loop looking for a start switch closure. It then calls a custom function (I guess that is a C++ subroutine??) that looks for one of four detector triggers or a stop switch closure, in a loop. Each detector trigger calls one of two different custom functions to energize and de-enrgize some relays. It then returns to the detection process. It only returns to the startup loop if it finds a stop switch closure in the detection process.
So I have to use custom functions as sub routines. I literally had to design each function by trial and error to get the program to compile. It wanted local variables identified individually for each custom function before it would compile (??). Nothing I read pointed out that requirement. What I needed was a book that explains the structure of programs, the required syntax as used in a program, and some templates to use. I searched the internet, bought and read two books, but in the end it came down to trial and error to get it to compile. I don't even know if it will run, as I need the extra hardware to prove that (???). That testing is next and I expect problems!
I really like the added features of the Ardunio UNO but the programming required sucks. Why would a device meant to teach microcontroller science use such a complex, under documented language like Ardunio C++? I suppose it is the next step beyond the Parallax Basic Stamp and has to be more capable but maybe someone should write a better programming book or offer an optional Basic compiler for it(??). I have helped my grandson with the Parallax stamp and it was fairly easy to program. Why can't the Ardunio community come up with an easier to use compiler?
Does anyone have any thoughts on this? Was it something I did wrong or is there a book I missed finding or is it required that you have a course on C++ to be prepared to use the Ardunio UNO? I am very hesitant to release the Ardunio UNO on my 11 year old grandson when I can not find documentation for what I had to do to get my program to compile. He is competent as a programmer for his age but this Ardunio C++ compiler is tough!
LDBennett