E Book Ultimate+Home+Automation+Using+Advance+AI+Assistant+JARVIS
E Book Ultimate+Home+Automation+Using+Advance+AI+Assistant+JARVIS
E Book Ultimate+Home+Automation+Using+Advance+AI+Assistant+JARVIS
The Arduino project started in 2003 as a program for students at the Interaction
Design Institute Ivrea in Ivrea, Italy, aiming to provide a low-cost and easy way
for novices and professionals to create devices that interact with their
environment using sensors and actuators. Common examples of such devices
intended for beginner hobbyists include simple robots, thermostats, and motion
detectors.
The name Arduino comes from a bar in Ivrea, Italy, where some of the founders
of the project used to meet. The bar was named after Arduin of Ivrea, who was
the margrave of the March of Ivrea and King of Italy from 1002 to 1014.
2] Different Arduino Boards
The original Arduino hardware was produced by the Italian company Smart
Projects. Some Arduino-branded boards have been designed by the American
companies SparkFun Electronics and Adafruit Industries. As of 2016, 17
versions of the Arduino hardware have been commercially produced.
3] Arduino Shields
Technical Specifics
Power
The Arduino Uno can be powered via the USB connection or with an external
power supply. The power source is selected automatically.
External (non-USB) power can come either from an AC-to-DC adapter (wall-
wart) or battery. The adapter can be connected by plugging a 2.1mm center-
positive plug into the board's power jack. Leads from a battery can be inserted in
the Gnd and Vin pin headers of the POWER connector.
The board can operate on an external supply of 6 to 20 volts. If supplied with less
than 7V, however, the 5V pin may supply less than five volts and the board may
be unstable. If using more than 12V, the voltage regulator may overheat and
damage the board. The recommended range is 7 to 12 volts.
VIN. The input voltage to the Arduino board when it's using an external
power source (as opposed to 5 volts from the USB connection or other
regulated power source). You can supply voltage through this pin, or, if
supplying voltage via the power jack, access it through this pin.
5V.This pin outputs a regulated 5V from the regulator on the board. The
board can be supplied with power either from the DC power jack (7 - 12V),
the USB connector (5V), or the VIN pin of the board (7-12V). Supplying
voltage via the 5V or 3.3V pins bypasses the regulator, and can damage
your board. We don't advise it.
3V3. A 3.3 volt supply generated by the on-board regulator. Maximum
current draw is 50 mA.
GND. Ground pins.
IOREF. This pin on the Arduino board provides the voltage reference with
which the microcontroller operates. A properly configured shield can read
the IOREF pin voltage and select the appropriate power source or enable
voltage translators on the outputs for working with the 5V or 3.3V.
Memory
The ATmega328 has 32 KB (with 0.5 KB used for the bootloader). It also has 2
KB of SRAM and 1 KB of EEPROM (which can be read and written with
the EEPROM library).
Each of the 14 digital pins on the Uno can be used as an input or output, using
pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts.
Each pin can provide or receive a maximum of 40 mA and has an internal pull-up
resistor (disconnected by default) of 20-50 kOhms. In addition, some pins have
specialized functions:
Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL
serial data. These pins are connected to the corresponding pins of the
ATmega8U2 USB-to-TTL Serial chip.
External Interrupts: 2 and 3. These pins can be configured to trigger an
interrupt on a low value, a rising or falling edge, or a change in value. See
the attachInterrupt() function for details.
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the
analogWrite() function.
SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI
communication using the SPI library.
LED: 13. There is a built-in LED connected to digital pin 13. When the pin
is HIGH value, the LED is on, when the pin is LOW, it's off. The Uno has 6
analog inputs, labeled A0 through A5, each of which provide 10 bits of
resolution (i.e. 1024 different values). By default they measure from ground
to 5 volts, though is it possible to change the upper end of their range using
the AREF pin and the analogReference() function. Additionally, some pins
have specialized functionality:
TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication
using the Wire library. There are a couple of other pins on the board:
AREF. Reference voltage for the analog inputs. Used with
analogReference().
Reset. Bring this line LOW to reset the microcontroller. Typically used to
add a reset button to shields which block the one on the board.
Communication
The Arduino Uno has a number of facilities for communicating with a computer,
another Arduino, or other microcontrollers. The ATmega328 provides UART
TTL (5V) serial communication, which is available on digital pins 0 (RX) and 1
(TX). An ATmega16U2 on the board channels this serial communication over
USB and appears as a virtual com port to software on the computer. The '16U2
firmware uses the standard USB COM drivers, and no external driver is needed.
However, on Windows, a .inf file is required. The Arduino software includes a
serial monitor which allows simple textual data to be sent to and from the
Arduino board. The RX and TX LEDs on the board will flash when data is being
transmitted via the USB-to-serial chip and USB connection to the computer (but
not for serial communication on pins 0 and 1).
The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino
software includes a Wire library to simplify use of the I2C bus; For SPI
communication, use the SPI library.
Programming
The Arduino Uno can be programmed with the Arduino software (download).
Select "Arduino Uno from the Tools > Board menu (according to the
microcontroller on your board
The ATmega328 on the Arduino Uno comes preburned with a bootloader that
allows you to upload new code to it without the use of an external hardware
programmer. It communicates using the original STK500 protocol.
You can also bypass the bootloader and program the microcontroller through the
ICSP (In-Circuit Serial Programming) header using Arduino ISP or similar.
The ATmega16U2 (or 8U2 in the rev1 and rev2 boards) firmware source code is
available. The ATmega16U2/8U2 is loaded with a DFU bootloader, which can
be activated by:
On Rev1 boards: connecting the solder jumper on the back of the board
(near the map of Italy) and then resetting the 8U2.
On Rev2 or later boards: there is a resistor that pulling the 8U2/16U2 HWB
line to ground, making it easier to put into DFU mode.
You can then use Atmel's FLIP software (Windows) or the DFU
programmer (Mac OS X and Linux) to load a new firmware. Or you can use the
ISP header with an external programmer (overwriting the DFU bootloader).
Rather than requiring a physical press of the reset button before an upload, the
Arduino Uno is designed in a way that allows it to be reset by software running
on a connected computer. One of the hardware flow control lines (DTR) of the
ATmega8U2/16U2 is connected to the reset line of the ATmega328 via a 100
nanofarad capacitor. When this line is asserted (taken low), the reset line drops
long enough to reset the chip. The Arduino software uses this capability to allow
you to upload code by simply pressing the upload button in the Arduino
environment. This means that the bootloader can have a shorter timeout, as the
lowering of DTR can be well-coordinated with the start of the upload.
This setup has other implications. When the Uno is connected to either a
computer running Mac OS X or Linux, it resets each time a connection is made
to it from software (via USB). For the following half-second or so, the bootloader
is running on the Uno. While it is programmed to ignore malformed data (i.e.
anything besides an upload of new code), it will intercept the first few bytes of
data sent to the board after a connection is opened. If a sketch running on the
board receives one-time configuration or other data when it first starts, make sure
that the software with which it communicates waits a second after opening the
connection and before sending this data.
The Uno contains a trace that can be cut to disable the auto-reset. The pads on
either side of the trace can be soldered together to re-enable it. It's labeled
"RESET-EN". You may also be able to disable the auto-reset by connecting a
110 ohm resistor from 5V to the reset line.
Physical Characteristics
The maximum length and width of the Uno PCB are 2.7 and 2.1 inches
respectively, with the USB connector and power jack extending beyond the
former dimension. Four screw holes allow the board to be attached to a surface or
case. Note that the distance between digital pins 7 and 8 is 160 mil (0.16"), not an
even multiple of the 100 mil spacing of the other pins.
7] Ohm’s Law
Ohm's law states that the current through a conductor between two points is
directly proportional to the voltage across the two points. Introducing the
constant of proportionality, the resistance, one arrives at the usual mathematical
equation that describes this relationship:
VαI
V = I×R (R is proportionality constant)
This law is also called Kirchhoff's first law, Kirchhoff's point rule, or Kirchhoff's
junction rule (or nodal rule).
The principle of conservation of electric charge implies that:
At any node (junction) in an electrical circuit, the sum of currents flowing
into that node is equal to the sum of currents flowing out of that node or
equivalently
This law is also called Kirchhoff's second law, Kirchhoff's loop (or mesh) rule,
and Kirchhoff's second rule.
The principle of conservation of energy implies that
The directed sum of the electrical potential differences (voltage)
around any closed network is zero, or:
More simply, the sum of the emfs in any closed loop is equivalent to
the sum of the potential drops in that loop, or:
1. Analog Communcation
2. Digital Communication
Analog System
The system in which signals take any value from a given range, and each
unique signal value represents different information.
V(t)
Digital System
The system in which signal is constructed from a discrete set of values.
10] Arduino IDE
void setup(){
// runs once
}
void loop(){
// repeats
}
File: Contains options to save, load, and print sketches; a thorough set of
example sketches to open; as well as the Preferences submenu
Edit: Contains the usual copy, paste, and search functions common to any
word processor
Sketch: Contains the function to verify your sketch before uploading to a
board, and some sketch folder and import options
Tools: Contains a variety of functions as well as the commands to select the
Arduino board type and USB port
Help: Contains links to various topics of interest and the version of the IDE
Verify : Click this to check that the Arduino sketch is valid and doesn’t
contain any programming mistakes.
Upload : Click this to verify and then upload your sketch to the Arduino
board.
New : Click this to open a new blank sketch in a new window.
Open : Click this to open a saved sketch.
Save : Click this to save the open sketch. If the sketch doesn’t have a name,
you will be prompted to create one.
Serial Monitor : Click this to open a new window for use in sending and
receiving data between your Arduino and the IDE.
Constants
A quantity or parameter that does not change its value
HIGH and LOW
INPUT and OUTPUT
Curly Braces
Curly braces defines the beginning and ending of function blocks and statement
blocks such as void loop() and for and if.
type function name()
{
statements;
}
Semicolon
A semicolon must be used to end a statements and to separate the elements
of the program.
Example:- int a;
Variable declaration
All variables have to be declared before they can be used.
Declaring a variable means defining it’s type as int, float, long etc.
This only needs to be done once in the program but the value can be
changed at any time using arithmetic or various assignment operators.
A variable can be declared at the beginning of the program before void
setup, locally inside the function, and sometimes within a statement block
such as for loops.
Example :- int led=13;
Comparison operators
Comparison of one variable or constant with another are often used to test
whether given condition is true.
X==Y // X is equal to Y
X!=Y // X is not equal to Y
X<Y // X is less than Y
X>Y // X is greater than Y
X<=Y // X is less than or equal to Y
X>=Y // X is greater than or equal to Y
Logical operators
Logical operators are way to compare two expressions and return a TRUE or
FALSE depending on the operator.
Logical AND
if(x>0 && x<5) // TRUE only if both expressions are true
Logical OR
if(x>0 || y>0) // TRUE only if either expression is true
Logical NOT
if(!x>0) // TRUE only if expression is false
Functions
A function is a block of code that has a name and a block of statements that are
executed when function is called.
Custom functions can be used to perform repetitive task.
Functions are declared by first declaring function type like int, void.
Type function name( parameters) {
statements;
}
14] Basic functions in Arduino
if()
If statement tests whether certain condition has been reached or not.
If the condition contained in the brackets() is TRUE the statements in side
curly braces executes.
If FALSE then the statements are skipped.
if ( condition ){
// dosomething;
}
if..else…
If….. Else….. Is used where we have “ either… or…..” decisions to be made.
if( condition){
do thing A;
}
else {
dothing B;
}
Algorithm
1. Apply 5v to trigger pin for 10 microseconds
2. Apply 0v to trigger pin for 2 microseconds.
3. Measure time period of echo pulse.
4. Distance is given by formula , D=time*340/(2*10000)
5. Observe in Serial monitor.