Iot Hardware and Software: Prof. Sourabh Bhaskar, Assistant Professor
Iot Hardware and Software: Prof. Sourabh Bhaskar, Assistant Professor
• Almost all Arduino modules are compatible with this software that is an open
source and is readily available to install and start compiling the code on the go.
Compiling Code
• Shields are boards that can be plugged on top of the Arduino PCB extending
its capabilities.
- Ethernet Shield
- Relay Shield
- Proto Shield
- Motor Shield
- LCD Shield
- Capacitive Touchpad Shield
- GSM/GPRS Shield
- microSD Shield
Arduino Basic Setup: Setting Up Your Environment
• A variable is a way of naming and storing a value for later use by the
program, such as data from a sensor or an intermediate value used in a
calculation.
• Example:
int inputVariable1;
int inputVariable2 = 0; // both are correct
Arduino - Operators
• An operator is a symbol that tells the compiler to perform specific
mathematical or logical functions. C language is rich in built-in operators and
provides the following types of operators −
- Arithmetic Operators
+-*/%
- Comparison Operators
== != < > <= >=
- Boolean Operators
&& || !
- Bitwise Operators
&|^
- Compound Operators
++ -- +=
Conditionals Loops : while
• A while loop will loop continuously, and infinitely, until the expression inside
the parenthesis, () becomes false.
• Syntax
while (condition) {
// statement(s)
}
• Example Code
var = 0;
while (var < 200) {
// do something repetitive 200 times
var++;
}
Conditionals Loops : for
• The for statement is used to repeat a block of statements enclosed in curly
braces. An increment counter is usually used to increment and terminate the
loop. The for statement is useful for any repetitive operation, and is often used
in combination with arrays to operate on collections of data/pins.
• Syntax
for (initialization; condition; increment) {
// statement(s);
}
Conditionals Loops : for
• Example Code
• loop()
In void loop(), your code will repeat over and over again.
Arduino - Functions
• For controlling the Arduino board and performing computations.
Digital I/O Time
- digitalRead() - delay()
- digitalWrite()
- pinMode()
Analog I/O
- analogRead()
- analogReference()
- analogWrite()
Arduino - Global Variables
• if you want to be able to use a variable anywhere in your program, you can
declare at the top of your code. This is called a global variable; here's an
example: