muhammad_nasif

Untitled

Apr 15th, 2021
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. /*
  2. * CharacterPrint_H_Offline_1.c
  3. *
  4. * Created: 4/13/2021 12:22:55 PM
  5. * Author : ASUS
  6. */
  7.  
  8.  
  9.  
  10. #define F_CPU 1000000UL
  11.  
  12. #include <avr/io.h>
  13. #include <util/delay.h>
  14. #include <avr/interrupt.h>
  15.  
  16. unsigned char flag = 1;
  17.  
  18.  
  19. ISR(INT1_vect){
  20. if (flag==0)
  21. {
  22. flag = 1;
  23. }
  24. else{
  25. flag = 0;
  26. }
  27. }
  28.  
  29.  
  30. int main(void)
  31. {
  32.  
  33. unsigned char x=1;
  34. unsigned int i=1;
  35. DDRA = 0xff;
  36. DDRB = 0xff;
  37. GICR =(1<<INT1);
  38. MCUCR = MCUCR | 0b00001100;
  39. sei();
  40. int val_1 = 1;
  41. int val_2 = 2;
  42. int val_3 = 4;
  43. int val_4 = 8;
  44. int a=0,b=0,c=0;
  45.  
  46.  
  47. PORTA = 0b00000001;
  48. PORTB = ~(0b01111100);
  49. while (1)
  50. {
  51. if(flag==1){
  52. _delay_ms(22);
  53. val_1 = val_1 << i;
  54. PORTA = val_1;
  55. if(PORTA == 0b00000000){
  56. val_1 = 1;
  57. PORTA = val_1;
  58. }
  59. PORTB = ~(0b01111100);
  60. _delay_ms(22);
  61. val_2 = val_2 << i;
  62. PORTA = val_2;
  63. if(PORTA == 0b00000000){
  64. val_2 = 1;
  65. PORTA = val_2;
  66. }
  67. PORTB = ~(0b00010000);
  68.  
  69. _delay_ms(22);
  70. val_3 = val_3 << i;
  71. PORTA = val_3;
  72. if(PORTA == 0b00000000){
  73. val_3 = 1;
  74. PORTA = val_3;
  75. }
  76. PORTB = ~(0b00010000);
  77.  
  78. _delay_ms(22);
  79. val_4 = val_4 << i;
  80. PORTA = val_4;
  81. if(PORTA == 0b00000000){
  82. val_4 = 1;
  83. PORTA = val_4;
  84. }
  85. PORTB = ~(0b01111100);
  86. }
  87. else{
  88. _delay_ms(1);
  89. PORTA = val_1;
  90. PORTB = ~(0b01111100);
  91. _delay_ms(1);
  92. PORTA = val_2;
  93. PORTB = ~(0b00010000);
  94.  
  95. _delay_ms(1);
  96. PORTA = val_3;
  97. PORTB = ~(0b00010000);
  98.  
  99. _delay_ms(1);
  100. PORTA = val_4;
  101. PORTB = ~(0b01111100);
  102. }
  103. }
  104. }
  105.  
  106.  
  107.  
  108. /*
  109. #include <avr/io.h>
  110. #include <avr/interrupt.h> //STEP1
  111.  
  112. ISR(INT1_vect)//STEP2
  113. {
  114. PORTB = ~PORTB;
  115. }
  116. int main(void)
  117. {
  118. DDRB = 0xFF;
  119. PORTB = 0b01010101;
  120. GICR = (1<<INT1); //STEP3
  121. MCUCR = MCUCR & 0b11110011;//STEP4
  122. sei();//STEP5
  123. while(1);
  124. }
  125. */
Advertisement
Add Comment
Please, Sign In to add comment