Arduino Basics - IoT

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Is Arduino a Microcontroller or

Microprocessor?
Arduino UNO is neither a microprocessor nor a
microcontroller. It is actually a development
board that uses a microcontroller called
Atmega328p to perform various functions. You can
say, atmega328p is the brain of the Arduino UNO
development board.
How many programs can Arduino
UNO run?
Arduino UNO is a simple microcontroller board
without any operating system or powerful
processor. Unlike your laptop or mobile phone, it
can run only one program at a time. Of course,
you can add multiple tasks in a single program
but they will be executed one by one.
Meet Arduino UNO

ATMEGA 328

Manufactured
by
ATMEL
The Arduino Development Board

Features
• +5 v Power supply
• 16MHz Clock speed
• 6 Analogue inputs
• 14 Digital I/O pins
• 6 PWM pins
• USB serial
• 32KB memory
Pulse Width Modulation
• Can’t use digital pins
to directly supply say
2.5V, but can pulse the
output on and off
really fast to produce
the same effect

• The on-off pulsing


happens so quickly,
the connected output
device “sees” the
result as a reduction
in the voltage
Other Arduino boards
 Arduino Mega 2560. It marries a more powerful ATmega
microcontroller to the same software environment,
providing 256KB of Flash storage, 8KB of RAM, three
more serial ports, a massive 54 GPIO pins (14 of those also
capable of PWM) and 16 ADCs.
 Alternatively, the more recent Arduino Due has a 32-bit
ARM core microcontroller and is the first of the Arduino
boards to use this architecture. Its specs are similar to the
Mega’s, although it ups the RAM to 96KB.
Structure of an Arduino “sketch”
The language usually used for Arduino is
a slightly modified dialect of C++ derived void setup()
from the Wiring platform. The code {
needs to provide only two routines: // put your setup code
here, to run once:
setup(): This routine is run once when
the board first boots. You could use it to }
set the modes of I/O pins to input or void loop()
output or to prepare a data structure
{
which will be used throughout the
program.
// put your main code
here, to run
loop(): This routine is run repeatedly in a repeatedly:
tight loop while the Arduino is switched
on. Typically, you might check some }
input, do some calculation on it, and
perhaps do some output in response.
List of Hands on Projects:
 Using LEDs:
i. LED blink
ii. Push button & LED
iii. Brightness control with push button
iv. Brightness control with pot
v. LED array
List of Hands on Projects:
 Using DC Motor
i. Forward and reversal of motors
ii. Motor with IR sensors

 Using LCD
i. Display
ii. Set cursor
iii. Auto scroll

 Timer with Buzzer


Getting Started
 Check out: http://arduino.cc/en/Guide/HomePage
1. Download & install the Arduino Integrated
Development Environment (IDE)
2. Connect the board to your computer via the USB cable
3. If needed, install the drivers
4. Launch the Arduino IDE
5. Select your board
6. Select your serial port
7. Open the blink example
8. Upload the program
To create a new project, select File -
-> New.
Upload the program to your board.

A- Used to check if there is any compilation error.


B- Used to upload a program to the Arduino board.
C- Shortcut used to create a new sketch.
D- Used to directly open one of the example sketch.
E- Used to save your sketch.
F- Serial monitor used to receive serial data from the board and send the
serial data to the board.
Before we begin coding

By Sebastian Goscik for EARS


Our First Program
Debugging
Although you need some debugging experience to be able to identify certain
compiler errors, others, like this one, are relatively easy to understand:

Blink.cpp: In function ‘void loop()’:Blink:21:


error:’digitalWritee’ was not declared in this scope

On line 21, in the function loop(), we deliberately misspelled the call to


digitalWrite.

You might also like