0% found this document useful (0 votes)
49 views48 pages

Iarjset-Ncdmete 13

This document provides an introduction to the Arduino prototyping platform, including descriptions of its major components and capabilities. It discusses the Arduino board and IDE software. It also covers various input/output functions like digital I/O, analog I/O, and serial communication. Specific topics include digital and analog pins, pulse width modulation for analog output, and using serial communication to send data to a computer. The document also includes exercises walking through using different I/O functions with the Arduino.

Uploaded by

Deepak sutar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views48 pages

Iarjset-Ncdmete 13

This document provides an introduction to the Arduino prototyping platform, including descriptions of its major components and capabilities. It discusses the Arduino board and IDE software. It also covers various input/output functions like digital I/O, analog I/O, and serial communication. Specific topics include digital and analog pins, pulse width modulation for analog output, and using serial communication to send data to a computer. The document also includes exercises walking through using different I/O functions with the Arduino.

Uploaded by

Deepak sutar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 48

Intro to the Arduino

Topics:
--The Arduino
--Digital IO
--Analog IO
--Serial Communication
--Pin configuration
--Features of Arduino
--LCD Display
--LED
What is Arduino ?
a. Arduino is an electronics prototyping platform based on
a micro controller.

b. Arduino boards are usually made using Atmel’s Atmega


series micro controllers or ARM micro controllers.

c. Arduino is an open source hardware project which


means the designs of board (the hardware architecture,
CAD files) are available to public with open source
license.

d. Anyone can modify the hardware designs and the


associated software.
“Arduino is composed of two major parts:

a. The Arduino board, which is the piece of hardware you


work on when you build your objects,

a. And the arduino IDE, the piece of software you run on


your computer. You use the IDE to create a sketch (a
little computer program) that you upload to the arduino
board. The sketch tells the board what to do.”
Topic 1: Meet Arduino Uno
Getting Started

1. Download & install the Arduino environment (IDE)


(not needed in lab)
2. Connect the board to your computer via the USB
cable
3. If needed, install the drivers (not needed in lab)
4. Launch the Arduino IDE
5. Select your board
6. Select your serial port
7. Open the blink example
8. Upload the program
Arduino IDE

See: http://arduino.cc/en/Guide/Environment for more information


Select Serial Port and Board
todbot.com/blog/bionicarduino
Input/Output

Image from Theory and Practice of Tangible User Interfaces at UC Berkley


Topic 2: Digital Input/Output

1
• Digital IO is binary
valued—it’s either on 0
or off, 1 or 0
• Internally, all
microprocessors are
digital, why?
Arduino Digital I/0

www.mikroe.com/chapters/view/1

pinMode(pin, mode)
Sets pin to either INPUT or OUTPUT
digitalRead(pin)
Reads HIGH or LOW from a pin
digitalWrite(pin, value)
Writes HIGH or LOW to a pin
Electronic stuff
Output pins can provide 40 mA of current
Writing HIGH to an input pin installs a 20KΩ pullup
Our First Program
IO Pins

Image from Theory and Practice of Tangible User Interfaces at UC Berkley


In-class Exercise 1: Digital IO

• Use a push-button to turn ON/Off LED


Topic 3: Analog Input
• Think about music stored on a CD---an analog
signal captured on digital media
– Sample rate
– Word length
Arduino Analog Input

Image credit: Tod Kurt

• Resolution: the number of different voltage levels (i.e.,


states) used to discretize an input signal
• Resolution values range from 256 states (8 bits) to
4,294,967,296 states (32 bits)
• The Arduino uses 1024 states (10 bits)
• Smallest measurable voltage change is 5V/1024 or 4.8 mV
• Maximum sample rate is 10,000 times a second
Concept: Analog vs. Digital
•Microcontrollers are digital devices – ON or OFF.

•An Analog signal is anything that can be a full


range of values. What are some examples? Think
of like a ramp or a hill.
How does ADC work?

• How does ADC work


• Excel Demonstration
Topic 3: Analog Output

• Can a digital devise produce analog


output?

Image from Theory and Practice of Tangible User Interfaces at UC Berkley

• Analog output can be simulated using


pulse width modulation (PWM)
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
PWM Duty Cycle
output voltage = (on_time / cycle_time) * 5V

Image credit: Tod Kurt

Fixed cycle length; constant


number of cycles/sec
PWM Pins

• Command:
analogWrite(pin,value)

• value is duty cycle:


between 0 and 255

• Examples:
analogWrite(9, 128)
for a 50% duty cycle

analogWrite(11, 64)
for a 25% duty cycle
Image from Theory and Practice of Tangible User Interfaces at UC Berkley
In-class Exercise 2: Analog IO
Part 1:

A light theremin
In-class Exercise 2: Analog IO

Part 2: Add an LED


• Add a 330 ohm resistor and an LED to
pin 9
• Using the analogWrite() command, set
the intensity of the LED as a function
of the value of prReading
Topic 4: Serial Communication

Image from http://www.ladyada.net/learn/arduino/lesson4.html


todbot.com/blog/bionicarduino
Serial Communication
• Compiling turns your program into
binary data (ones and zeros)
• Uploading sends the bits through
USB cable to the Arduino
• The two LEDs near the USB
connector blink when data is
transmitted
• RX blinks when the Arduino is
receiving data
• TX blinks when the Arduino is
transmitting data
todbot.com/blog/bionicarduino
Open the Serial Monitor and
Upload the Program
Some Commands
• Serial.begin()
- e.g., Serial.begin(9600)
• Serial.print() or Serial.println()
- e.g., Serial.print(value)
• Serial.read()
• Serial.available()
• Serial.write()
• Serial.parseInt()

• Example Program
Serial-to-USB chip---what does it do?

The LilyPad and Fio Arduino require an external USB to


TTY connector, such as an FTDI “cable”.
In the Arduino Leonardo a single microcontroller runs the
Arduino programs and handles the USB connection.

Image from Theory and Practice of Tangible User Interfaces at UC Berkley


Two different communication
protocols
Serial (TTL):
USB Protocol

• Much more complicated


In-class Exercise 3: Serial
Communication
Modify your program from in-class
exercise 2-part 2 to control the
intensity of the LED attached to pin 9
based on keyboard input.

Use the Serial.parseInt() method to


read numeric keyboard input as an
integer.

An input of 9 should produce full


intensity and an input of 0 should turn
the LED off.
In-class Exercise 4: Pin
configuration
UART Peripheral:
A UART (Universal Asynchronous Receiver/Transmitter) is a serial interface. The
ATmega328 has only one UART module.

The pins (RX, TX) of the UART are connected to a USB-to-UART converter circuit
and also connected to pin0 and pin1 in the digital header. You must avoid using the
UART if you’re already using it to send/receive data over USB.

SPI Peripheral:
The SPI (Serial Peripheral Interface) is another serial interface. The ATmega328 has
only one SPI module.

Besides using it as a serial interface, it can also be used to program the MCU using
a standalone programmer. You can reach the SPI's pins from the header next to the
MCU in the Arduino UNO board or from the digital header as below:

11<->MOSI
12<->MISO
13<->SCK
TWI:
The I2C or Two Wire Interface is an interface consisting of only two wires, serial data,
and a serial clock: SDA, SCL.
You can reach these pins from the last two pins in the digital header or pin4 and pin5
in the analog header.
Other Functionality:

Other functionality is included in the MCU, such as that offered by the


timer/counter modules. You may not be aware of the functions that you don't
use in your code. You can refer to the datasheet for more information.

ADC Inputs:
This MCU has six channels—PORTC0 to PORTC5—with 10-bit resolution
A/D converter. These pins are connected to the analog header on the
Arduino board.
Pin Descriptions : -
Vcc & Gnd : Digital supply voltage and Ground.

Port B : XTAL1/XTAL2/TOSC1/TOSC2 :
•Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each
bit).
•The Port B output buffers have symmetrical drive characteristics with both high sink and
source capability. As inputs,
•Port B pins that are externally pulled low will source current if the pull-up resistors are
activated.
•The Port B pins are tri-stated when a reset condition becomes active, even if the clock
is not running.

Port C PC[5:0] :
•Port C is a 7-bit bi-directional I/O port with internal pull-up resistors (selected for each
bit).
• The PC[5:0] output buffers have symmetrical drive characteristics with both high sink
and source capability. As inputs,
•Port C pins that are externally pulled low will source current if the pull-up resistors are
activated.
•The Port C pins are tri-stated when a reset condition becomes active, even if the clock
is not running.
Pin Descriptions : -
PC6/RESET :
•If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin.
•If the RSTDISBL Fuse is unprogrammed, PC6 is used as a Reset input. A low level on
this pin for longer than the minimum pulse length will generate a Reset, even if the clock
is not running.

Port D (PD[7:0]) :
•Port D is an 8-bit bi-directional I/O port with internal pull-up resistors.
• The Port D pins are tri-stated when a reset condition becomes active, even if the clock
is not running.

AVCC:
•AVCC is the supply voltage pin for the A/D Converter, It should be externally connected
to VCC, If the ADC is used, it should be connected to VCC Through a low-pass filter.

AREF : AREF is the analog reference pin for the A/D Converter.

ADC[7:6] : ADC[7:6] serve as analog inputs to the A/D converter.


•These pins are powered from the analog supply and serve as 10-bit ADC channels.
LCD Display
•LCD Display : LCD (Liquid Crystal Display) is an
electronic display which is commonly used
nowadays in applications such as calculators,
laptops, tablets, mobile phones etc.16×2 character
LCD module is a very basic module which is
commonly used by electronic hobbyists and is
used in many electronic devices and projects.

•16×2 LCD with Interfaced


With a microcontroller
LCD Connections
•Display units - big or small, work on the same basic principle. Besides
complex display units like graphic displays and 3D dispays.
•In 16x2 LCD there are 16 pins over all if there is a back light, if there is no
back light there will be 14 pins.
• One can power or leave the back light pins. Now in the 14 pins there are 8
data pins (7-14 or D0-D7), 2 power supply pins (1&2 or VSS&VDD or
GND&+5v), 3rd pin for contrast control (VEE-controls how thick the characters
should be shown), and 3 control pins (RS&RW&E).
The connections which are done for LCD are given below:
• PIN1 or VSS to ground
• PIN2 or VDD or VCC to +5v power
• PIN3 or VEE to ground (gives maximum contrast best for a beginner)
• PIN4 or RS (Register Selection) to PIN0 of ARDUINO UNO
• PIN5 or RW (Read/Write) to ground (puts LCD in read mode eases the
communication for user)
• PIN6 or E (Enable) to PIN1 of ARDUINO UNO
• PIN11 or D4 to PIN8 of ARDUINO UNO
• PIN12 or D5 to PIN9 of ARDUINO UNO
• PIN13 or D6 to PIN10 of ARDUINO UNO
• PIN14 or D7 to PIN11 of ARDUINO UNO
Interface a 16x2 LCD with
ARDUINO UNO
Code
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(0, 1, 8, 9, 10, 11); /// REGISTER SELECT PIN,ENABLE PIN,D4 PIN,D5
PIN, D6 PIN, D7 PIN
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}

void loop()
{
// set the cursor to column 0, line 1
lcd.print(" CIRCUIT DIGEST");//print name
lcd.setCursor(0, 1); // set the cursor to column 0, line 2
lcd.print("www.circuitdigest.com");//print name
delay(750);//delay of 0.75sec
lcd.scrollDisplayLeft();//shifting data on LCD
lcd.setCursor(0, 0);// set the cursor to column 0, line1
}
LED
•We are going blink LED(Light emmiting diode) using
Arduino, A light-emitting diode (LED) is a semiconductor
device that emits visible light when an electric current
passes through it.
•An LED consists of two elements of processed material P-
type and N-type semiconductors. These two elements are
placed in direct contact, forming a region called the P-N
junction.

LED Symbol
About LED
•The Light emitting diode is a two-lead semiconductor light
source. LED allows the flow of current in the forward
direction and blocks the current in the reverse direction.
•The working principle of the Light emitting diode is based
on the quantum theory.
•The quantum theory says that when the electron comes
down from the higher energy level to the lower energy level
then, the energy emits from the photon.
•LED is a semiconductor device used in many electronic
devices, mostly used for signal transmission /power
indication purposes.
• It is very cheaply and easily available in a variety of
shape, color, and size.
•The LEDs are also used for design message display
boards and traffic control signal lights etc.
LED Interfacing with Arduino UNO
The arduino uno board comes with a pre installed LED at port
number 13. This is a small SMD LED marked L and you can find
it near port 13, To test the LED blink program, you don’t need to
connect a separate LED.
Code
const int LED = 13;

void setup()
{
pinMode(LED,OUTPUT);
}
void loop()
{
digitalWrite(LED,HIGH);
delay(1000);
digitalWrite(LED,LOW);
delay(1000);
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy