Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.32 KB | None | 0 0
  1. // **************************************************************************
  2. //
  3.  
  4. //               Demo program for labs
  5. //
  6. // Subject:      Computer Architectures and Parallel systems
  7. // Author:       Petr Olivka, petr.olivka@vsb.cz, 08/2016
  8. // Organization: Department of Computer Science, FEECS,
  9. //               VSB-Technical University of Ostrava, CZ
  10. //
  11. // File:         Main program for LEDs
  12. //
  13. // **************************************************************************
  14.  
  15. #include \"mbed.h\"
  16.  
  17.  
  18.     /*DigitalOut leds[8] = { PTC0, PTC1, PTC2, PTC3, PTC4, PTC5, PTC7, PTC8 };
  19.  
  20.     DigitalIn but( PTC9 );*/
  21.  
  22.     DigitalOut b(PTB2);
  23.     DigitalIn but1( PTC9 );
  24.     DigitalIn but2( PTC10 );
  25.  
  26. int main()
  27. {
  28.     int jas=10;
  29.     bool but1stav=false;
  30.     bool but2stav=false;
  31.     int x=0;
  32.  
  33.     while(true){
  34.         if(x%5==0){
  35.             but1stav=false;
  36.             but2stav=false;
  37.         }
  38.  
  39.         if(!but1 && jas!=20 && but1stav==false){
  40.             jas++;
  41.             but1stav=true;
  42.         }
  43.  
  44.         if(!but2 && jas!=0 && but2stav==false){
  45.             jas--;
  46.             but2stav=true;
  47.         }
  48.  
  49.         for(int i =0;i<20;i++){
  50.  
  51.             if(i<jas){
  52.                 b=1;
  53.             }
  54.             else{
  55.                 b=0;
  56.             }
  57.             wait_ms(1);
  58.         }
  59.  
  60.         x++;
  61.     }
  62.  
  63.     /*bool stop=false;
  64.  
  65.         int delay = 150;
  66.  
  67.  
  68.         while(true){
  69.  
  70.  
  71.             for(int i=0;i<8;i++){
  72.  
  73.                 if(!but){
  74.                     stop=true;
  75.                 }
  76.                 leds[i] = 1;
  77.  
  78.                 wait_ms(delay);
  79.  
  80.                 leds[i] = 0;
  81.                 if(i==7){
  82.                     leds[i] = 1;
  83.                 }
  84.             }
  85.  
  86.             while(stop){
  87.                 wait_ms(1);
  88.                 if(but){
  89.                     stop = false;
  90.                 }
  91.             }
  92.  
  93.  
  94.             for(int i=8;i>0;i--){
  95.  
  96.                 if(!but){
  97.                     stop=true;
  98.                 }
  99.  
  100.                 leds[i] = 1;
  101.  
  102.                 wait_ms(delay);
  103.  
  104.                 leds[i] = 0;
  105.             }
  106.  
  107.                 leds[0] = 1;
  108.             while(stop){
  109.  
  110.                 wait_ms(1);
  111.                 if(but){
  112.                     stop = false;
  113.                 }
  114.             }
  115.  
  116.         }  */
  117.  
  118.  
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement