Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * GccApplication3.c
- * exp4.c
- * Created: 11/13/2017 8:24:25 PM
- * Author: Rifat
- */
- #define F_CPU 1000000UL
- #include <avr/io.h>
- #include<util/delay.h>
- unsigned char ROR(unsigned char number,int shiftamount)
- {
- int i;
- for(i=0;i<shiftamount;i++)
- {
- unsigned char LSB=number & 0x01;
- LSB=LSB<<7;
- number=number>>1;
- number=number|LSB;
- }
- return number;
- }
- unsigned char ROL(unsigned char number,int shiftamount)
- {
- int i;
- for(i=0;i<shiftamount;i++)
- {
- unsigned char MSB=number & 0x80;
- MSB=MSB>>7;
- number=number<<1;
- number=number|MSB;
- }
- return number;
- }
- void matrixRotateRight(unsigned char *character)
- {
- int i;
- for(i=0;i<8;i++)
- {
- character[i]=ROL(character[i],1);
- }
- }
- void drawChar(unsigned char *character)
- {
- int i;
- for(i=0;i<10;i++)
- {
- int j;
- unsigned char row=0x01;
- for(j=0;j<8;j++)
- {
- PORTA=ROL(row,j);
- PORTD=character[j];
- _delay_us(50);
- }
- }
- }
- int main(void)
- {
- unsigned char T[]={0xFF,0xbd,0xbd,0xbd,0x01,0xbf,0xbf,0xbf};//4 print
- unsigned char t1[]={0xFe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
- unsigned char t2[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
- unsigned char J[] = {
- 0b10000001,
- 0b10111111,
- 0b10111111,
- 0b10111111,
- 0b10111101,
- 0b10111101,
- 0b11000011,
- 0b11111111
- };
- unsigned char A[] = {
- 0b11111111,
- 0b11100111,
- 0b11011011,
- 0b11011011,
- 0b11000011,
- 0b11011011,
- 0b11011011,
- 0b11111111
- };
- unsigned char O[] = {
- 0b00000000,
- 0b00111100,
- 0b00111100,
- 0b00111100,
- 0b00111100,
- 0b00111100,
- 0b00111100,
- 0b00000000
- };
- unsigned char F[] = {
- 0b00000000,
- 0b11111100,
- 0b11111100,
- 0b11000000,
- 0b11111100,
- 0b11111100,
- 0b11111100,
- 0b11111100
- };
- unsigned char L[] = {
- 0b11111100,
- 0b11111100,
- 0b11111100,
- 0b11111100,
- 0b11111100,
- 0b11111100,
- 0b00000000,
- 0b11111111
- };
- unsigned char I[] = {
- 0b11100111,
- 0b11100111,
- 0b11100111,
- 0b11100111,
- 0b11100111,
- 0b11100111,
- 0b11100111,
- 0b11111111
- };
- unsigned char N[] = {
- 0b01111100,
- 0b01111000,
- 0b01110100,
- 0b01101100,
- 0b01011100,
- 0b00111100,
- 0b01111100,
- 0b11111111
- };
- unsigned char E[] = {
- 0b00000000,
- 0b11111100,
- 0b11111100,
- 0b11000000,
- 0b11111100,
- 0b11111100,
- 0b00000000,
- 0b11111111
- };
- unsigned char S[] = {
- 0b11000011,
- 0b11111011,
- 0b11111011,
- 0b11000011,
- 0b11011111,
- 0b11011111,
- 0b11000011,
- 0b11111111,
- };
- unsigned char A1[] = {
- 0b11111111,
- 0b11100111,
- 0b11011011,
- 0b11011011,
- 0b11000011,
- 0b11011011,
- 0b11011011,
- 0b11111111
- };
- DDRD=0xff;
- DDRA=0xff;
- /* Task 1 only print*/
- /*
- while(1)
- {
- drawChar(S);
- //drawChar(t2);
- //TODO:: Please write your application code
- }*/
- /*Task 2 Blink*/
- /*
- int jj;
- while(1)
- {
- for(jj=0;jj<15;jj++)
- {
- drawChar(S);
- }
- PORTA=0;
- _delay_ms(300);
- }*/
- /*Task 3 Rotation*/
- int jj;
- int ii;
- while(1)
- {
- matrixRotateRight(S);
- for(jj=0;jj<50;jj++)
- {
- drawChar(S);
- }
- //
- }
- //while(1)
- //{
- //PORTA=0x01;
- //PORTD=0b01111111;
- //_delay_us(50);
- //int kk;
- //for(kk=0;kk<7;kk++)
- //{
- //PORTA=PORTA<<1;
- //
- //PORTD=PORTD>>1;
- //PORTD=PORTD|0x80;
- //_delay_us(50);
- //}
- //}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement