Difference between revisions of "Digital technologies/Arduino/Arduino- Beginner"

From CEED Wiki
Jump to navigation Jump to search
Line 4: Line 4:
 
A mico-controller is a compact integrated circuit that receives input from the environment, processes the input and can produce an output. It receives input from its I/O pins and processes the signals received using the CPU onboard the chip. Micro-controllers are usually embedded in larger systems and are utilized in many areas of life including vehicles, medical devices, home appliances, and more.
 
A mico-controller is a compact integrated circuit that receives input from the environment, processes the input and can produce an output. It receives input from its I/O pins and processes the signals received using the CPU onboard the chip. Micro-controllers are usually embedded in larger systems and are utilized in many areas of life including vehicles, medical devices, home appliances, and more.
  
=== Arduino board sections ===
+
===Arduino board sections===
 
There are 5 important board sections that the user must have a solid understanding of to complete the project. These sections are outlined below:
 
There are 5 important board sections that the user must have a solid understanding of to complete the project. These sections are outlined below:
<br />
+
{| class="wikitable"
 +
|+Table 1: Description of the 5 main sections of an arduino board
 +
!Section
 +
!Description
 +
|-
 +
|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.
 +
|-
 +
|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.
 +
|-
 +
|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.
 +
|-
 +
|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.
 +
|-
 +
|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.
 +
|}
 +
 
 +
=== 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.
 +
 
 +
==== 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.
 +
 
 +
==== 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).
 +
 
 +
== Basic Understanding of Programming ==
 +
 
 +
=== 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.
 +
 
 +
Some other basic considerations:
 +
{| class="wikitable"
 +
|+Table 2: Overview of some basic elements of programming
 +
!
 +
!Symbol
 +
!Description
 +
|-
 +
|Brackets
 +
|{....}
 +
|Starts and ends a function or is used to group different statements together
 +
|-
 +
|Comment bars
 +
|/* ….*/ 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!
 +
|-
 +
|Semicolon
 +
|...;
 +
|This character ends a program statement and lets the compiler know ‘the end of the current line/statement’
 +
|}
 +
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 ===

Revision as of 18:55, 22 August 2021

Understanding of the Arduino Board

What is a micro-controller?

A mico-controller is a compact integrated circuit that receives input from the environment, processes the input and can produce an output. It receives input from its I/O pins and processes the signals received using the CPU onboard the chip. Micro-controllers are usually embedded in larger systems and are utilized in many areas of life including vehicles, medical devices, home appliances, and more.

Arduino board sections

There are 5 important board sections that the user must have a solid understanding of to complete the project. These sections are outlined below:

Table 1: Description of the 5 main sections of an arduino board
Section Description
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.
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.
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.
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.
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.

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.

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.

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).

Basic Understanding of Programming

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: https://www.arduino.cc/en/software. 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.

Some other basic considerations:

Table 2: Overview of some basic elements of programming
Symbol Description
Brackets {....} Starts and ends a function or is used to group different statements together
Comment bars /* ….*/ 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!
Semicolon ...; This character ends a program statement and lets the compiler know ‘the end of the current line/statement’

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