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

Input Output Programming in AVR Microcontroller

Robo India in this presentation presents the Input and Output programming in AVR Micro Controllers namely Atmega 16, Atmega 8, Atmega 328, Atmega 32 etc. As in robotics, automation and embedded system Input and Output programming is essential. This presentation describes how to use input and output ports, resisters of AVR microcontroller. If you have any query please write us, we are found at- website:http://roboindia.com mail: [email protected]

Uploaded by

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

Input Output Programming in AVR Microcontroller

Robo India in this presentation presents the Input and Output programming in AVR Micro Controllers namely Atmega 16, Atmega 8, Atmega 328, Atmega 32 etc. As in robotics, automation and embedded system Input and Output programming is essential. This presentation describes how to use input and output ports, resisters of AVR microcontroller. If you have any query please write us, we are found at- website:http://roboindia.com mail: [email protected]

Uploaded by

Robo India
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Robo India

Input / output programming in


AVR microcontroller

INPUT/OUTPUT

PORTS

Atmega16 have total of 40 pins


32 I/O pins..
PORT
PORT
PORT
PORT

A
B
C
D

=
=
=
=

8 Pins
8 Pins
8 Pins
8 Pins

I/O PORT REGISTER

Port
X
DDRX

PORTX

PINX

NOTE:- X is the name of port


and it can
be A, B, C or D .

USES OF REGISTER
DDRX For setting the direction i.e. Input
or output.
PORTX For setting output value of port.
PINX For reading data available in port.
NOTE:- X is the name of port and it can be
A,
B, C or D .

DEFINING PORT
(DATA DIRECT REGISTER)
DDRX= 0xFF; (O/P-Port)
DDRX= 0x00; (I/P-Port)
or
DDRX = 0b 1 1 1 1 1 1 1 1 ; (O/PPort)
DDRX = 0b 0 0 0 0 0 0 0 0 ; (I/PPort)
NOTE:- X is the name of port and it
can
be A, B, C or D .

OUTPUT (PORT - REGISTER)


1. PORTX= 0xF0 ;
PORTX = 0b 1 1 1 1 0 0 0 0 ;
2. PORTX= 0xFF ;
PORTX = 0b 1 1 1 1 1 1 1 1;
3. PORTX= 0x00 ;
PORTX = 0b 0 0 0 0 0 0 0 0;

CONDITION AND LOOP


1.If
if ( conditions )
{ code to be executed }
2.For loop
for(start ; condition ; step)
{code to be executed}
3.While loop
while( Condition)
{ code to be executed }

INPUT (PIN - REGISTER)


bit_is_clear(PINX,0)) //No input

bit_is_set(PINX,0))
input

//Detecting

IF - LOOP
if (bit_is_set(PINX,0)))
{ code to be executed }
if (bit_is_clear(PINX,0)))
{ code to be executed }

WHILE - LOOP
while(bit_is_set(PINX,0)))
{ code to be executed }
while(bit_is_clear(PINX,0)))
{ code to be executed }

INCLUDE

#include <avr/io.h>
#include <util/delay.h>

THANKS

In case of queries please write


[email protected]

You might also like