Mestima

lab4_microProc

May 31st, 2021
1,366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. int DELAY = 100;
  2. char data_;
  3. int delays[] = {100, 200, 300, 50};
  4. int flag = 0;
  5.  
  6. int i = 0x01;
  7. int j = 0;
  8. void blinc() {
  9.     for (i = 0x01; i < 0x09; i = i << 1) {
  10.         LATA = i;
  11.         if (i == 0x01) {
  12.              Sound_Play(1337, 10);
  13.         } else {
  14.           Sound_Play(684, 10);
  15.         }
  16.         Delay_ms(10);
  17.         LATA = 0x00;
  18.         for (j = 0; j < DELAY; j++) {
  19.             Delay_ms(1);
  20.         }
  21.     }
  22. }
  23.  
  24. void main() {
  25.   ANSELC = 0;
  26.   TRISA = 0;
  27.   Sound_Init(&PORTE, 1);
  28.   UART1_Init(9600);
  29.   Delay_ms(100);
  30.  
  31.   while(1) {
  32.       if (UART1_Data_Ready()) {
  33.         data_ = UART1_Read();
  34.         flag += 1;
  35.         if (flag > 3) flag = 0;
  36.         DELAY = delays[flag];
  37.         Sound_Play(2048, 100);
  38.         Delay_ms(100);
  39.       }
  40.       blinc();
  41.   }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment