Changes

Jump to navigation Jump to search
no edit summary
Line 12: Line 12:  
|-
 
|-
 
|USB connector
 
|USB connector
|The arduino can be powered through a type A/B USB connector from the user’s laptop/computer to the board. This port is also used to upload programs onto the board.  
+
|The arduino can be powered through a type A/B USB connector from the user’s laptop/computer to the board. This port is also used to upload programs onto the board.
 
|-
 
|-
 
|Power port
 
|Power port
|The arduino board can be powered through an AC-DC adapter or a battery. The power jack of the board can be connected to a 2.1 mm center-positive plug.  
+
|The arduino board can be powered through an AC-DC adapter or a battery. The power jack of the board can be connected to a 2.1 mm center-positive plug.
 
|-
 
|-
 
|Power pins
 
|Power pins
 
|To power external circuitry, 3 standard voltages (0 V or GND, 3.3V, 5V) are provided in the ‘Power Pins’ section of the board.
 
|To power external circuitry, 3 standard voltages (0 V or GND, 3.3V, 5V) are provided in the ‘Power Pins’ section of the board.
 
|-
 
|-
|Digital pins  
+
|Digital pins
 
|Digital pins on the arduino board can be configured as an input or an output. When the pins are configured as an input, the pins will send a binary signal into the board, which enables the board to read the sensed logic voltage levels (ie. either 0/low or 1/high). If the digital pins are configured as an output, then the arduino will send a binary signal to the pin.  There is a built-in LED pre-connected to digital pin 13. When the value of the pin is driven HIGH by the processor, the LED on the board is illuminated, when the pin is LOW, it's turned off. This can be used as a status indicator when programs are running.
 
|Digital pins on the arduino board can be configured as an input or an output. When the pins are configured as an input, the pins will send a binary signal into the board, which enables the board to read the sensed logic voltage levels (ie. either 0/low or 1/high). If the digital pins are configured as an output, then the arduino will send a binary signal to the pin.  There is a built-in LED pre-connected to digital pin 13. When the value of the pin is driven HIGH by the processor, the LED on the board is illuminated, when the pin is LOW, it's turned off. This can be used as a status indicator when programs are running.
 
|-
 
|-
|Analog pins  
+
|Analog pins
 
|The analog pins allow the arduino board to receive or send an analog signal. These signals need to be converted into digital representations which can be used inside the software-executing portion of the Arduino processor (which only uses binary digital signals). Analog signal inputs can be accepted for conversion into digital via the Analog Pins header. The Analog to Digital (A/D or “A to D”) conversion is done inside the processor with specialized circuitry.
 
|The analog pins allow the arduino board to receive or send an analog signal. These signals need to be converted into digital representations which can be used inside the software-executing portion of the Arduino processor (which only uses binary digital signals). Analog signal inputs can be accepted for conversion into digital via the Analog Pins header. The Analog to Digital (A/D or “A to D”) conversion is done inside the processor with specialized circuitry.
 
|}
 
|}
   −
=== Analog VS Digital signals ===
+
===Analog VS Digital signals===
 
A signal is an electromagnetic or electric current that transfers information from one source to another. There are two main types of signals used in electronics: analog or digital signals.  
 
A signal is an electromagnetic or electric current that transfers information from one source to another. There are two main types of signals used in electronics: analog or digital signals.  
   −
==== Analog signals ====
+
====Analog signals====
 
This is a time-varying and continuous type of signal that is often used to measure changes in light, sound, position, temperature, or other physical phenomena. When plotted in a voltage-time graph, the result is often a continuous and smooth curve.
 
This is a time-varying and continuous type of signal that is often used to measure changes in light, sound, position, temperature, or other physical phenomena. When plotted in a voltage-time graph, the result is often a continuous and smooth curve.
   −
==== Digital signals ====
+
====Digital signals====
 
A digital signal is a signal that represents information as a series of discrete binary values. Digital signals are used in all modern electronic applications, including communication and network devices. When plotted in a voltage-time graph, the signal is discrete, and ranges from 0 V to VCC (usually 1.8V, 3.3 V, or 5V).
 
A digital signal is a signal that represents information as a series of discrete binary values. Digital signals are used in all modern electronic applications, including communication and network devices. When plotted in a voltage-time graph, the signal is discrete, and ranges from 0 V to VCC (usually 1.8V, 3.3 V, or 5V).
   −
== Basic Understanding of Programming ==
+
==Basic Understanding of Programming==
   −
=== Introduction to coding ===
+
===Introduction to coding===
 
The process of programming includes designing and executing code in an integrated development environment, otherwise known as an IDE. Many different IDEs exist and are adopted for different usages, and allow programs to edit, debug, and execute (or compile) their code. In order to program an arduino, one must have the Arduino IDE downloaded, which can be accessed from here: <nowiki>https://www.arduino.cc/en/software</nowiki>. The arduino IDE provides users with a programming editor as well as a way to easily upload and compile programs onto the arduino board. Programmes in the arduino IDE are called sketches, and are normally saved with the .ino extension. The language used to programme the arduino board is based on the C++ language, which is a general use Object Oriented language. Like any common language, in order to start coding, one must be aware of the grammar rules and vocabulary that is used. An important word that will be often encountered is a “function”, which is a block of code that takes in an input, processes the input, then returns an output.  
 
The process of programming includes designing and executing code in an integrated development environment, otherwise known as an IDE. Many different IDEs exist and are adopted for different usages, and allow programs to edit, debug, and execute (or compile) their code. In order to program an arduino, one must have the Arduino IDE downloaded, which can be accessed from here: <nowiki>https://www.arduino.cc/en/software</nowiki>. The arduino IDE provides users with a programming editor as well as a way to easily upload and compile programs onto the arduino board. Programmes in the arduino IDE are called sketches, and are normally saved with the .ino extension. The language used to programme the arduino board is based on the C++ language, which is a general use Object Oriented language. Like any common language, in order to start coding, one must be aware of the grammar rules and vocabulary that is used. An important word that will be often encountered is a “function”, which is a block of code that takes in an input, processes the input, then returns an output.  
   Line 54: Line 54:  
|Comment bars
 
|Comment bars
 
|/* ….*/ or //
 
|/* ….*/ or //
|Allows coders to add comments to their code to make it more readable to other humans. Important to note that all comments do not get executed by the program and therefore do not alter the program!  
+
|Allows coders to add comments to their code to make it more readable to other humans. Important to note that all comments do not get executed by the program and therefore do not alter the program!
 
|-
 
|-
 
|Semicolon
 
|Semicolon
Line 62: Line 62:  
It is also important to be aware that the arduino editor is case sensitive, meaning that the words “DOOR” and “Door” are not understood to be the same word by the compiler. Furthermore, to make writing and editing code more friendly, the arduino IDE will color code important functions, comments, etc. This will be seen later in this section.  
 
It is also important to be aware that the arduino editor is case sensitive, meaning that the words “DOOR” and “Door” are not understood to be the same word by the compiler. Furthermore, to make writing and editing code more friendly, the arduino IDE will color code important functions, comments, etc. This will be seen later in this section.  
   −
=== Variables ===
+
===Variables===
 +
Variables allow  information in programmes to be stored or changed within the code. In order to create a variable within your program, it must be declared. To declare a variable, the coder has to write the type of variable to be declared first. Different types exist, most commonly used are:
 +
{| class="wikitable"
 +
|+Table 3: Summary of commonly used variable types
 +
!Type
 +
!Syntax
 +
|-
 +
|Integers
 +
|int
 +
|-
 +
|non-integers (rational and non-rational)
 +
|dpuble or float
 +
|-
 +
|charecters
 +
|char
 +
|}
 +
After declaring the variable type, the coder must then name the variable. The variable name should clearly reflect the purpose of the value, so that the coder and the reader can easily identify which value is associated with what variable. Additionally, variables cannot have spaces imbedded within the name. For example, "My deposit" is not a valid variable name, but "MyDeposit" is. Note that capitalizations can be useful for readability. Furthermore, variables should not start with digits, or with an underscore "_".
 +
 
 +
After naming the variable, the coder can choose to initialize the variable, which is choosing an initial value to be assosiated with the variable (which can change throughout the program). Be careful to stay consistent with the type of the variable. For example, you cannot initialize the variable int Age with a value of "k", as "k" is not an integer. The code segments below illustrate the process of initialization:
 +
int a;// not initialized, which is ok!
 +
 
 +
double b=1.23;/* Note that the 1.23 value matches with the “double” type which is a rational number*/
 +
 
 +
char MyVariable = “h”; //note the semicolons!
 +
The following will produce an error, which will disable the compiler from compiling your code:
 +
char YourVariable= 1.23; // 1.23 is not a character!
 +
Variables can be classified into either global or local variables. The main difference is the scope at which they can be accessed. A global variable can be accessed by all functions that exist within a program, whereas a local variable can be accessed through only the function where it is declared. The example below illustrates this well [https://www.arduino.cc/reference/en/language/variables/variable-scope-qualifiers/scope/<nowiki>]:</nowiki>
 +
/* There are two functions in this program: setup() and loop(), and three variables: "k", "i", "f".*/
 +
 
 +
int k;  // any function will see this variable, thus called a global variable.
 +
 
 +
void setup() {
 +
 
 +
   // ... }
 +
 
 +
void loop() {
 +
 
 +
   int i;    // "i" is only "visible" inside of "loop"
 +
 
 +
   float f; }  // "f" is only "visible" inside of "loop"
 +
 
 +
.....// some lines of code}
 +
 
 +
=== Arduino IDE ===
 +
After getting introduced to some of the basic structures of coding, its important to get to know the integrated development enviroment, or IDE that the coder will use to edit and compile the written programmes. For all arduino boards, the IDE used is the Arduino IDE, available online at: https://www.arduino.cc/en/software. <!-- Need to insert a figure here
 +
-->
 +
<br />
MakerRepo Staff, makerrepo-staff
27

edits

Navigation menu