Programming the Arduino

04/01/2021


(this is only "Getting started")

First: Any CPU or Controller is as dumb as a post until you tell it what to do, and even then it is an "Idiot Savant " (most controllers are not "Plug & Play")

Second: The Programmer and the Controller have to speak the same language (Proper "Syntax")

The actual code is initially simply text descriptions of desired actions, and the Compiler is a program that converts the text into machine code for the Controller

Every programmer has their own style and approach to a project at hand.

That style may change somewhat depending on the type of project, and even the language in use.

Every Language has its individual "Nuances", which is a nice way of describing the rules and requirements.

There are however, certain principles which should be considered for anyone new to programming.

Programming Language

The common language for Arduinos is C and C++

Routines for the Arduino are called "Sketches", with the file type "xxxx.ino", and the Compiler expects them to be be in a folder by the same name.

Individual routines are basically in 4 major segments:

User-written Modules are usually installed after the loop

// All modules require the void xxxxx and the braces { } to enclose the code

void HeatWater() // Calls the Module for Heating

void Wait(int 3) // Calls the Module Wait, with "3" as a passed parameter

Techniques

/* Comments */

// Comments (to end of line)

Definitions:

byte – int – float – boolean – String

Aid in trouble-shooting your Routine:

Operators:

Pin Setup: { Tri-State / Bi-Directional Transceivers }

Actions: (Pin Controls)

LCD Controls:

Sample Sketches (Routines or Programs)

The old adage that says "give me an example:

There are a HUGE bunch of sample Routines (Sketches) included in the Arduino (IDE) Program.

Using the IDE, click on File > Examples > Built-in Examples

Sample Sketch #1: BLINK-RGB.ino - RGB_LED (Schematic), RGB Illustration [ Special, just for this group. A small breadboard, jumpers, and 330 ohm resistors required ]

Sample Sketch #2: QST Project (the one that started it all for me)

Sample Sketch #3: Sequence_Relays (Seed Relay Shield – no LCD)

Sample Sketch #4: Furnace-Conrol (Custom Shield)

Sample Sketch #5: Ping_Pwang (Ultrasonic Transducers)

Sample Sketch #6: Key_Grab (PBs by Analog Input using voltage divider(s))

Downloaded Routines (Sketches) should have the file type ".ino" and be placed in a folder by the same name, without the file type.

The Arduino Compiler expects this.

In the IDE, you should:

Return to Arduino "Talking Points"