Advertisement
Ostu

Untitled

May 24th, 2021
2,334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <avr/io.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5.  
  6. int main(void)
  7. {
  8. char string[]="atz"; //komunikat
  9. char string1[]={'$',0x20,0x20,0x20,'*'};
  10. char a[20];
  11. int i=0,j=0,Z;
  12.  
  13. UCSRB=(1<<TXEN);
  14. UBRRL=207;
  15.  
  16. Z=string[0]^string[1]^string[2];
  17. itoa(Z,a,16);
  18.  
  19. while(1)
  20. {
  21.  
  22.  
  23.     for(j=0;j<7;j++)
  24.     {
  25.         if(j>0 && j<4)
  26.         {
  27.             string1[j]=string[j-1];
  28.         }
  29.         if(j==5)
  30.         {
  31.             string[j]=a[0];
  32.         }
  33.     }
  34.  
  35.  
  36.  
  37.     for (i=0;i<strlen(string1)+2;i++)
  38.     {
  39.         if(i==strlen(string1))
  40.         {
  41.             UDR=0x0D;
  42.         }
  43.         if(i==strlen(string1)+1)
  44.         {
  45.             UDR=0x0A;
  46.         }
  47.         if(i>=0 && i<strlen(string1))
  48.         {
  49.             UDR=string1[i];
  50.         }
  51.         while(!(UCSRA&(1<<TXC)));
  52.         UCSRA|=(1<<TXC);
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement