Arduino
Arduino
2
Features of Arduino
●
Inexpensive
●
Cross-platform
●
Simple, clear programming environment
●
Open source and extensible software
●
Open source and extensible hardware
3
Arduino’s ATmega328
●
Alf and Vegard's RISC processor.
●
ATMEGA328P is high performance, low power
controller from Microchip.
●
ATMEGA328P is an 8-bit microcontroller based on
AVR RISC architecture. It is the most popular of all
AVR controllers as it is used in ARDUINO boards.
4
Pins
Serial pin - TxO RAW– i/p volt regulator
Serial pin-RxI GND- Ground
Reset input -RST RST- Reset input
Ground-GND VCC-Dig. power supply
2- Digital i/o A3 – Reads analog sig.
3 A2
4 A1
5 A0
6 13 -Digital i/o
7 12
8 11
9 10
5
Writing Sketches
●
Programs written using Arduino Software (IDE) are
called sketches.
●
These sketches are written in the text editor and
are saved with the file extension .ino.
●
Uploading: you need to select the correct items
from the Tools > Board and Tools > Port menus.
6
●
Current Arduino boards will reset automatically and begin the
upload.
●
you'll see the RX and TX LEDs blink as the sketch is uploaded.
The Arduino Software (IDE) will display a message when the
upload is complete, or show an error.
●
Serial Monitor: Choose the baud rate from the drop-down menu
that matches the rate passed to Serial.begin in your sketch.
7
Arduino Program structure
●
Arduino programs can be divided in three main parts:
Structure, Values (variables and constants), and
Functions.
●
Software structure consist of two main functions −
– setup( ) function : initialize variables, pins, run only once
– loop( ) function : allowing your program to change and respond
8
LED BLINK Program
// the setup function runs once when you press reset or power the board
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // initialize digital pin LED_BUILTIN as an output.
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
9
How 16×2 LCDs work
●
An LCD is an electronic display module which uses
liquid crystal to produce a visible image. The 16×2 LCD
display is a very basic module commonly used in DIYs
and circuits.
●
The 16×2 translates o a display 16 characters per line
in 2 such lines. In this LCD each character is displayed
in a 5×7 pixel matrix.
10
11
12
13