mikolajmki

mikro_lab3

Apr 26th, 2022 (edited)
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.38 KB | None | 0 0
  1. /*
  2.  * lab3.c
  3.  *
  4.  * Created: 26.04.2022 15:35:03
  5.  * Author : Student_PL
  6.  */
  7. #ifndef F_CPU
  8. #define F_CPU 1000000UL
  9. #endif
  10. #include <avr/io.h>
  11. #include <util/delay.h>
  12.  
  13. char array[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
  14. char tablica[] = {0b10000110, 0b10100011};
  15.  
  16.  
  17. int main(void)
  18. {
  19.     DDRA = 0b11111111;
  20.     DDRB = 0b11111111;
  21.  
  22.     while (1)
  23.     {
  24.         PORTA = tablica[0];
  25.         PORTB = 0b00001011;
  26.         _delay_ms(1000);
  27.         PORTA = tablica[1];
  28.         PORTB = 0b00001110;
  29.         _delay_ms(1000);
  30.         /*for(int i=0;i<10;i++)
  31.         {
  32.             PORTA = array[i];
  33.             _delay_ms(50);
  34.         }*/
  35.     }
  36. }
  37.  
  38. /*
  39.  * lab3.c
  40.  *
  41.  * Created: 26.04.2022 15:35:03
  42.  * Author : Student_PL
  43.  */
  44. #ifndef F_CPU
  45. #define F_CPU 1000000UL
  46. #endif
  47. #include <avr/io.h>
  48. #include <util/delay.h>
  49.  
  50. char array[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
  51. char tablica[] = {0b10000110, 0b10100011};
  52. char tablica_liczba[] = {0xF9, 0x92, 0xF9, 0x82};
  53.  
  54.  
  55. int main(void)
  56. {
  57.     DDRA = 0b11111111;
  58.     DDRB = 0b11111111;
  59.  
  60.     while (1)
  61.     {
  62.         PORTA = tablica_liczba[0];
  63.         PORTB = 0b00000111;
  64.         _delay_ms(1);
  65.         PORTA = tablica_liczba[1];
  66.         PORTB = 0b00001011;
  67.         _delay_ms(1);
  68.         PORTA = tablica_liczba[0];
  69.         PORTB = 0b00001101;
  70.         _delay_ms(1);
  71.         PORTA = tablica_liczba[3];
  72.         PORTB = 0b00001110;
  73.         _delay_ms(1);
  74.         /*for(int i=0;i<10;i++)
  75.         {
  76.             PORTA = array[i];
  77.             _delay_ms(50);
  78.         }*/
  79.     }
  80. }
  81.  
  82.  
Add Comment
Please, Sign In to add comment