NaMaLiCS Tutorial Part 2, the Arduino IDE

  • WRTyler
  • -the National Mall guy-
  • wrTyler
  • 3 yrs ago

I am using the IDE that Arduino provides for programming it's products.  I normally use another code editor, but because the Arduino IDE is used to compile the code and send it to the Arduino itself, you have to go through the IDE at some point in time.  So I decided to use it as my primary coding editor.

Up to this point, every Arduino program I've written has been small enough that everything could reside in a single file.  However, NaMaLiCS quickly became unwieldy to navigate through as I would bounce between different sections of the code.  Using code folding was nice to collapse parts of the program so they were easy to skip over, but I found that when I started another coding session and opened the program, the code folding I had set up was gone and I would have to set it up again for that session.

Had to be a better way...and there was.  You can create tabs in the IDE.  Each tab can contain a different section of the code.  The first image shows what NaMaLiCS looks like currently in the IDE.  The second image shows what the program (or sketch in Arduino terms) looks when viewed with Windows File Explorer.  Each tab corresponds to a separate .ino file.

You will also notice that the tabs / .ino files are labelled A_, B_, C_, etc.  That is because when the IDE loads the individual files, it opens the main file (which is the name of the entire program / sketch) first and then each additional file in alphabetical order.  To make sure the files I created got loaded in the order I wished, I prefaced the tab / file names in alphabetical order.

Why does the order of the files matter?  Because if you use a variable or function before it is declared, the program will produce an error.  So, if you look at the tab / file names you will notice that:

- The second file loaded contains all the global variables...along with loading the needed libraries.

- The third file loaded sets up the initial conditions need to run the program.

- The fourth file is the main loop executed by the program

- The subsequent files are individual lighting effects called in the main loop of the program

Next, we'll start looking at code specifics.

-wrtyler-

Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like1 Follow
  • 1 Likes
  • 3 yrs agoLast active
  • 36Views
  • 1 Following