Atmega16 C program to send hex values for ASCII characters 0,1,2,3,4,5,A,B,C and D to port PB.

A program to send hex values for ASCII characters.

#include<avr/io.h>
int main(void)
{
unsigned char num[] = '012345ABCD';
//save the data in a char
unsigned char x;

//here we are using unsigned char so that out hex file dosent get big .

//i.e. unsigned char ranges only from 0 to 255 .

DDRB = 0*FF; // this will set Reg B as total output i.e set every bit to 1

for(x=0;x<10;x++)
{
PORTB = num[x];
//this will select one item from num one at a time.
}

while(1);
//the code will stay here forever

return 0;
}




Comments

Popular Posts