input output programming in avr microcontroller
TRANSCRIPT
![Page 1: Input Output programming in AVR microcontroller](https://reader036.vdocument.in/reader036/viewer/2022082209/55a698bb1a28ab602d8b48ab/html5/thumbnails/1.jpg)
![Page 2: Input Output programming in AVR microcontroller](https://reader036.vdocument.in/reader036/viewer/2022082209/55a698bb1a28ab602d8b48ab/html5/thumbnails/2.jpg)
• Atmega16 have total of 40 pins
32 I/O pins..
PORT “A” = 8 Pins
PORT “B” = 8 Pins
PORT “C” = 8 Pins
PORT “D” = 8 Pins
![Page 3: Input Output programming in AVR microcontroller](https://reader036.vdocument.in/reader036/viewer/2022082209/55a698bb1a28ab602d8b48ab/html5/thumbnails/3.jpg)
Port “X”
DDRX PORTX PINX
NOTE:- X is the name of port and it can be A, B, C or D .
![Page 4: Input Output programming in AVR microcontroller](https://reader036.vdocument.in/reader036/viewer/2022082209/55a698bb1a28ab602d8b48ab/html5/thumbnails/4.jpg)
• 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 .
Click here to visit -ROBO INDIA
![Page 5: Input Output programming in AVR microcontroller](https://reader036.vdocument.in/reader036/viewer/2022082209/55a698bb1a28ab602d8b48ab/html5/thumbnails/5.jpg)
DDRX= 0xFF; (O/P-Port)
DDRX= 0x00; (I/P-Port)
or
DDRX = 0b 1 1 1 1 1 1 1 1 ; (O/P-Port)
DDRX = 0b 0 0 0 0 0 0 0 0 ; (I/P-Port)
NOTE:- X is the name of port and it can be A, B, C or D .
Click here to visit -ROBO INDIA
![Page 6: Input Output programming in AVR microcontroller](https://reader036.vdocument.in/reader036/viewer/2022082209/55a698bb1a28ab602d8b48ab/html5/thumbnails/6.jpg)
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;
Click here to visit -ROBO INDIA
![Page 7: Input Output programming in AVR microcontroller](https://reader036.vdocument.in/reader036/viewer/2022082209/55a698bb1a28ab602d8b48ab/html5/thumbnails/7.jpg)
1.Ifif ( conditions ){ code to be executed }
2.For loopfor(start ; condition ; step){code to be executed}
3.While loopwhile( Condition){ code to be executed }
Click here to visit -ROBO INDIA
![Page 8: Input Output programming in AVR microcontroller](https://reader036.vdocument.in/reader036/viewer/2022082209/55a698bb1a28ab602d8b48ab/html5/thumbnails/8.jpg)
bit_is_clear(PINX,0)) //No input
bit_is_set(PINX,0)) //Detecting input
Click here to visit -ROBO INDIA
![Page 9: Input Output programming in AVR microcontroller](https://reader036.vdocument.in/reader036/viewer/2022082209/55a698bb1a28ab602d8b48ab/html5/thumbnails/9.jpg)
if (bit_is_set(PINX,0)))
{ code to be executed }
if (bit_is_clear(PINX,0)))
{ code to be executed }
Click here to visit -ROBO INDIA
![Page 10: Input Output programming in AVR microcontroller](https://reader036.vdocument.in/reader036/viewer/2022082209/55a698bb1a28ab602d8b48ab/html5/thumbnails/10.jpg)
while(bit_is_set(PINX,0)))
{ code to be executed }
while(bit_is_clear(PINX,0)))
{ code to be executed }
Click here to visit -ROBO INDIA
![Page 11: Input Output programming in AVR microcontroller](https://reader036.vdocument.in/reader036/viewer/2022082209/55a698bb1a28ab602d8b48ab/html5/thumbnails/11.jpg)
• #include <avr/io.h>
• #include <util/delay.h>
Click here to visit -ROBO INDIA
![Page 12: Input Output programming in AVR microcontroller](https://reader036.vdocument.in/reader036/viewer/2022082209/55a698bb1a28ab602d8b48ab/html5/thumbnails/12.jpg)
In case of queries please write us-
www.roboindia.comClick here to visit -ROBO INDIA