Primer on using the Arduino

Reference Guide:
Please review the link below to get a general overview of the commands that are part of the C-based programming language which is used in the development of "code" used to control the various functions of the Arduino. 

Arduino Reference Guide

Overview and soapbox time:
The following are "beginning Arduino-based coding examples". These examples purposely DO NOT INCLUDE any hardware as it is my belief that you need to understand the basic programming structure of the Arduino before you begin to "interface" the Arduino with electrical devices. In other words I am an educator who understands how people learn as I am re-teaching myself the C Programming structure. I haven't used C since the late 1980s but I do have nack at programming (I use to do some programming in assembly/machine language) as well as having a degree in electronics with over 20 years of teaching experience (my day job). Please trust me that you do need to understand the code/sketches if you wish to do anything other than simply copy code/sketches using pre-drawn wiring diagrams to interface various electrical devices to the Arduino!

The code in these examples will only display information in the Serial Monitor windows of the Arduino IDE just so you know...not very sexy I know.


Program-1
This is a program that will allow the Arduino to display text to the Serial Monitor window which is part of the Arduino IDE. To access the Serial Monitor click on the Tools menu item and then select Serial Monitor drop down menu list.


















Program-2
This is a program displays information using both the setup and void functions. Please note that code located in the setup function will only execute once v.s any code located in the void function will continuously repeat. 














Program-3
This is a program is identical to program 2 except for the fact that the code located in the void function will only be executed once. 














Program-4
This is a simple program creates two integer-based variables in each of the two functions. Please note any variables created within the setup function can only be used by code located within the setup function-variable valueA cannot be used in the void function.

Variable Scope:
Within the C language which has been modified to work with the Arduino that variables fall into two classifications which are listed below:

  • Global Variables
     -these variables are defined outside of the setup() and void() functions
    -these variables can be referenced (used) by both the setup() and void() functions.
  • Local Variables
    -these variables are defined inside of the setup() and void() functions
    -these variables can be referenced (used) only by the function they are assigned  within-either the setup() and void() functions. 


1 comment:

  1. Programming is very interesting and creative thing if you do it with love. Your blog code helps a lot to beginners to learn programming from basic to advance level. I really love this blog because I learn a lot from here and this process is still continuing.
    Love from Pro Programmer

    ReplyDelete