Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. /*
  2. * GccApplication3.c
  3. * exp4.c
  4. * Created: 11/13/2017 8:24:25 PM
  5. * Author: Rifat
  6. */
  7.  
  8.  
  9. #define F_CPU 1000000UL
  10. #include <avr/io.h>
  11. #include<util/delay.h>
  12.  
  13. unsigned char ROR(unsigned char number,int shiftamount)
  14. {
  15. int i;
  16. for(i=0;i<shiftamount;i++)
  17. {
  18.  
  19. unsigned char LSB=number & 0x01;
  20. LSB=LSB<<7;
  21. number=number>>1;
  22. number=number|LSB;
  23. }
  24. return number;
  25. }
  26.  
  27. unsigned char ROL(unsigned char number,int shiftamount)
  28. {
  29. int i;
  30. for(i=0;i<shiftamount;i++)
  31. {
  32.  
  33. unsigned char MSB=number & 0x80;
  34. MSB=MSB>>7;
  35. number=number<<1;
  36. number=number|MSB;
  37. }
  38. return number;
  39. }
  40.  
  41. void matrixRotateRight(unsigned char *character)
  42. {
  43. int i;
  44. for(i=0;i<8;i++)
  45. {
  46. character[i]=ROL(character[i],1);
  47. }
  48. }
  49.  
  50. void drawChar(unsigned char *character)
  51. {
  52. int i;
  53. for(i=0;i<10;i++)
  54. {
  55. int j;
  56. unsigned char row=0x01;
  57. for(j=0;j<8;j++)
  58. {
  59. PORTA=ROL(row,j);
  60. PORTD=character[j];
  61. _delay_us(50);
  62. }
  63. }
  64. }
  65.  
  66. int main(void)
  67. {
  68. unsigned char T[]={0xFF,0xbd,0xbd,0xbd,0x01,0xbf,0xbf,0xbf};//4 print
  69. unsigned char t1[]={0xFe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
  70. unsigned char t2[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
  71.  
  72. unsigned char J[] = {
  73. 0b10000001,
  74. 0b10111111,
  75. 0b10111111,
  76. 0b10111111,
  77. 0b10111101,
  78. 0b10111101,
  79. 0b11000011,
  80. 0b11111111
  81. };
  82.  
  83. unsigned char A[] = {
  84. 0b11111111,
  85. 0b11100111,
  86. 0b11011011,
  87. 0b11011011,
  88. 0b11000011,
  89. 0b11011011,
  90. 0b11011011,
  91. 0b11111111
  92. };
  93.  
  94. unsigned char O[] = {
  95. 0b00000000,
  96. 0b00111100,
  97. 0b00111100,
  98. 0b00111100,
  99. 0b00111100,
  100. 0b00111100,
  101. 0b00111100,
  102. 0b00000000
  103. };
  104.  
  105. unsigned char F[] = {
  106. 0b00000000,
  107. 0b11111100,
  108. 0b11111100,
  109. 0b11000000,
  110. 0b11111100,
  111. 0b11111100,
  112. 0b11111100,
  113. 0b11111100
  114. };
  115.  
  116. unsigned char L[] = {
  117. 0b11111100,
  118. 0b11111100,
  119. 0b11111100,
  120. 0b11111100,
  121. 0b11111100,
  122. 0b11111100,
  123. 0b00000000,
  124. 0b11111111
  125. };
  126.  
  127. unsigned char I[] = {
  128. 0b11100111,
  129. 0b11100111,
  130. 0b11100111,
  131. 0b11100111,
  132. 0b11100111,
  133. 0b11100111,
  134. 0b11100111,
  135. 0b11111111
  136. };
  137.  
  138. unsigned char N[] = {
  139. 0b01111100,
  140. 0b01111000,
  141. 0b01110100,
  142. 0b01101100,
  143. 0b01011100,
  144. 0b00111100,
  145. 0b01111100,
  146. 0b11111111
  147. };
  148.  
  149. unsigned char E[] = {
  150. 0b00000000,
  151. 0b11111100,
  152. 0b11111100,
  153. 0b11000000,
  154. 0b11111100,
  155. 0b11111100,
  156. 0b00000000,
  157. 0b11111111
  158. };
  159.  
  160.  
  161. unsigned char S[] = {
  162. 0b11000011,
  163. 0b11111011,
  164. 0b11111011,
  165. 0b11000011,
  166. 0b11011111,
  167. 0b11011111,
  168. 0b11000011,
  169. 0b11111111,
  170. };
  171. unsigned char A1[] = {
  172. 0b11111111,
  173. 0b11100111,
  174. 0b11011011,
  175. 0b11011011,
  176. 0b11000011,
  177. 0b11011011,
  178. 0b11011011,
  179. 0b11111111
  180. };
  181.  
  182. DDRD=0xff;
  183. DDRA=0xff;
  184.  
  185. /* Task 1 only print*/
  186. /*
  187. while(1)
  188. {
  189.  
  190. drawChar(S);
  191. //drawChar(t2);
  192. //TODO:: Please write your application code
  193. }*/
  194.  
  195.  
  196. /*Task 2 Blink*/
  197. /*
  198. int jj;
  199. while(1)
  200. {
  201. for(jj=0;jj<15;jj++)
  202. {
  203. drawChar(S);
  204. }
  205. PORTA=0;
  206. _delay_ms(300);
  207. }*/
  208.  
  209. /*Task 3 Rotation*/
  210.  
  211. int jj;
  212. int ii;
  213. while(1)
  214. {
  215. matrixRotateRight(S);
  216. for(jj=0;jj<50;jj++)
  217. {
  218. drawChar(S);
  219. }
  220. //
  221. }
  222.  
  223. //while(1)
  224. //{
  225. //PORTA=0x01;
  226. //PORTD=0b01111111;
  227. //_delay_us(50);
  228. //int kk;
  229. //for(kk=0;kk<7;kk++)
  230. //{
  231. //PORTA=PORTA<<1;
  232. //
  233. //PORTD=PORTD>>1;
  234. //PORTD=PORTD|0x80;
  235. //_delay_us(50);
  236. //}
  237. //}
  238. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement