0% found this document useful (0 votes)
6 views

Arduino Notes

An Arduino kit is a microcontroller-based kit used for communication and controlling devices, founded in 2005 by Massimo Banzi and David Cuartielles. The Arduino architecture features a Harvard design with separate program and data memory, and programming can be done easily through a bootloader without additional hardware. The document also outlines how to program an Arduino, design custom boards, and provides coding examples for basic functionalities like LED control.

Uploaded by

anshismyname47
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Arduino Notes

An Arduino kit is a microcontroller-based kit used for communication and controlling devices, founded in 2005 by Massimo Banzi and David Cuartielles. The Arduino architecture features a Harvard design with separate program and data memory, and programming can be done easily through a bootloader without additional hardware. The document also outlines how to program an Arduino, design custom boards, and provides coding examples for basic functionalities like LED control.

Uploaded by

anshismyname47
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Arduino Kit

An Arduino kit is actually a microcontroller based kit which can be either used directly by purchasing
from the vendor or can be made at home using the components, owing to its open source hardware
feature. It is basically used in communica ons and in controlling or opera ng many devices. It was
founded by Massimo Banzi and David Cuar elles in 2005.

Arduino Architecture:
Arduino’s processor basically uses the Harvard architecture where the program code and program data
have separate memory. It consists of two memories‐ Program memory and the data memory. The code
is stored in the flash program memory, whereas the data is stored in the data memory. The Atmega328
has 32 KB of flash memory for storing code (of which 0.5 KB is used for the bootloader), 2 KB of SRAM
and 1 KB of EEPROM and operates with a clock speed of 16MHz.

Arduino Pin Diagram


A typical example of Arduino board is Arduino Uno. It consists of ATmega328 ‐ a 28 pin microcontroller.
Arduino Pin Diagram

Arduino Uno consists of 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog
inputs, a 16 MHz crystal oscillator, a USB connec on, a power jack, an ICSP header, and a reset bu on.

Power Jack: Arduino can be power either from the pc through a USB or through external source like
adaptor or a ba ery. It can operate on a external supply of 7 to 12V. Power can be applied externally
through the pin Vin or by giving voltage reference through the IO Ref pin.

Digital Inputs: It consists of 14 digital inputs/output pins, each of which provide or take up 40 mA
current. Some of them have special func ons like pins 0 and 1, which act as Rx and Tx respec vely, for
serial communica on, pins 2 and 3‐which are external interrupts, pins 3,5,6,9,11 which provides PWM
output and pin 13 where LED is connected.

Analog inputs: It has 6 Analog input/output pins, each providing a resolu on of 10 bits.

ARef: It provides reference to the analog inputs

Reset: It resets the microcontroller when low.

How to program an Arduino?


The most important advantage with Arduino is the programs can be directly loaded to the device
without requiring any hardware programmer to burn the program. This is done because of the
presence of the 0.5KB of Bootloader which allows the program to be burned into the circuit. All we
have to do is to download the Arduino so ware and wri ng the code.

The Arduino tool window consists of the toolbar with the bu ons like verify, upload, new, open, save,
serial monitor. It also consists of a text editor to write the code, a message area which displays the
feedback like showing the errors, the text console which displays the output and a series of menus like
the File, Edit, Tools menu.
5 Steps to program an Arduino

 Programs wri en in Arduino are known as sketches. A basic sketch consists of 3 parts

1. Declara on of Variables
2. Ini aliza on: It is wri en in the setup () func on.
3. Control code: It is wri en in the loop () func on.

 The sketch is saved with .ino extension. Any opera ons like verifying, opening a sketch, saving
a sketch can be done using the bu ons on the toolbar or using the tool menu.

 The sketch should be stored in the sketchbook directory.

 Chose the proper board from the tools menu and the serial port numbers.

 Click on the upload bu on or chose upload from the tools menu. Thus the code is uploaded
by the bootloader onto the microcontroller.

Few of basic Adruino func ons are:

 digitalRead(pin): Reads the digital value at the given pin.

 digitalWrite(pin, value): Writes the digital value to the given pin.

 pinMode(pin, mode): Sets the pin to input or output mode.

 analogRead(pin): Reads and returns the value.

 analogWrite(pin, value): Writes the value to that pin.

 serial.begin(baud rate): Sets the beginning of serial communica on by se ng the bit rate.

How to Design your own Arduino?

We can also design our own Arduino by following the schema c given by the Arduino vendor and also
available at the websites. All we need are the following components‐ A breadboard, a led, a power
jack, a IC socket, a microcontroller, few resistors, 2 regulators, 2 capacitors.

 The IC socket and the power jack are mounted on the board.

 Add the 5v and 3.3v regulator circuits using the combina ons of regulators and capacitors.

 Add proper power connec ons to the microcontroller pins.


 Connect the reset pin of the IC socket to a 10K resistor.

 Connect the crystal oscillators to pins 9 and 10

 Connect the led to the appropriate pin.

 Mount the female headers onto the board and connect them to the respec ve pins on the
chip.

 Mount the row of 6 male headers, which can be used as an alterna ve to upload programs.

 Upload the program on the Microcontroller of the readymade Adruino and then pry it off and
place back on the user kit.

7 Reasons why Arduino is being preferred these days

1. It is inexpensive

2. It comes with an open source hardware feature which enables users to develop their own kit
using already available one as a reference source.

3. The Arduino so ware is compa ble with all types of opera ng systems like Windows, Linux,
and Macintosh etc.

4. It also comes with open source so ware feature which enables experienced so ware
developers to use the Arduino code to merge with the exis ng programming language libraries
and can be extended and modified.

5. It is easy to use for beginners.

6. We can develop an Arduino based project which can be completely stand alone or projects
which involve direct communica on with the so ware loaded in the computer.

7. It comes with an easy provision of connec ng with the CPU of the computer using serial
communica on over USB as it contains built in power and reset circuitry.

So this is some basic idea regarding an Arduino. You can use it for many types of applica ons. For
instance in applica ons involving controlling some actuators like motors, generators, based on the
input from sensors.

Arduino Coding
The setup() func on is called when a sketch starts. Use it to ini alize variables, pin modes, start using
libraries, etc. The setup func on will only run once, a er each powerup or reset of the board.

A er crea ng a setup() func on, the loop() func on does precisely what its name suggests, and loops
consecu vely, allowing your program to change and respond as it runs. Code in the loop() sec on of
your sketch is used to ac vely control the board.

The code below won't actually do anything, but it's structure is useful for copying and pas ng to get
you started on any sketch of your own. It also shows you how to make comments in your code.

Any line that starts with two slashes (//) will not be read by the compiler, so you can write anything
you want a er it. The two slashes may be put a er func onal code to keep comments on the same
line. Commen ng your code like this can be par cularly helpful in explaining, both to yourself and
others, how your program func ons step by step.

void setup() {

// put your setup code here, to run once:

}
void loop() {

// put your main code here, to run repeatedly:

Arduino code examples:


LED Blink
Turns an LED on for one second, then off for one second, repeatedly. Most Arduinos have an on‐board
LED you can control. LED_BUILTIN is set to the correct LED pin independent of which board is used.

// the setup func on runs once when you press reset or power the board

void setup() {

// ini alize digital pin LED_BUILTIN as an output.

pinMode(LED_BUILTIN, OUTPUT);

// the loop func on 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 1000 milli seconds

digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW

delay(1000); // wait for 1000 milli seconds

LED Fade
This Arduino program shows how to fade an LED on pin 9 using the analogWrite() func on. The
analogWrite() func on uses PWM, so if you want to change the pin you're using, be sure to use
another PWM capable pin.

On most Arduino boards, the PWM pins are iden fied with a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11.

int led = 9; // the PWM pin the LED is a ached to

int brightness = 0; // how bright the LED is

int fadeAmount = 5; // how many points to fade the LED by

// the setup rou ne runs once when you press reset:


void setup() {

// declare pin 9 to be an output:

pinMode(led, OUTPUT);

// the loop rou ne runs over and over again forever:

void loop() {

// set the brightness of pin 9:

analogWrite(led, brightness);

// change the brightness for next me through the loop:

brightness = brightness + fadeAmount;

// reverse the direc on of the fading at the ends of the fade:

if (brightness <= 0 || brightness >= 255) {

fadeAmount = ‐ fadeAmount;

// wait for 30 milliseconds to see the dimming effect

delay(30);

You might also like