Iarjset-Ncdmete 13
Iarjset-Ncdmete 13
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.
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
• Command:
analogWrite(pin,value)
• 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
• Example Program
Serial-to-USB chip---what does it do?
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:
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.
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);
}