Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 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, 09/2019
  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. #include <vector>
  17.  
  18. // Serial line for printf output
  19. Serial g_pc(USBTX, USBRX);
  20.  
  21. // LEDs on K64F-KIT - instances of class DigitalOut
  22.  
  23.  
  24. // Button on K64F-KIT - instance of class DigitalIn
  25.  
  26. DigitalIn g_but9(PTC9);
  27. DigitalIn g_but10(PTC10);
  28. DigitalIn g_but11(PTC11);
  29. DigitalIn g_but12(PTC12);
  30.  
  31.  
  32. DigitalOut Hled[] = {PTC0,PTC1,PTC2,PTC3,PTC4,PTC5,PTC7,PTC8};
  33.  
  34. struct LED{
  35. public:
  36.     LED(PinName pin):led(pin){};
  37.     void turn_on(){
  38.             led=1;
  39.      };
  40.     void turn_off(){
  41.         led=0;
  42.     };
  43.     int get_brightness(){
  44.  
  45.     };
  46.     void set_brightness(int value);
  47.  
  48. private:
  49.     DigitalOut led;
  50.     int brightness;
  51. };
  52.  
  53. int main()
  54. {
  55.  
  56.     // Serial line initialization
  57.     //g_pc.baud(115200);
  58.     int c = 2;
  59.     int k = 2;
  60.    
  61.     while (1)
  62.     {
  63.         if(g_but9 == 0 && g_but10 == 1 && g_but11 == 1 && g_but12 == 1)
  64.         {
  65.             Hled[0] = 1;
  66.         }
  67.         if(g_but9 == 1 && g_but10 == 0 && g_but11 == 1 && g_but12 == 1)
  68.         {
  69.             Hled[1] = 1;
  70.             Hled[0] = 0;
  71.         }
  72.         if(!g_but11)
  73.         {
  74.             Hled[0] = 0;
  75.         }
  76.         if(!g_but11)
  77.         {
  78.             if(c % 2 == 0)
  79.             {
  80.                 for(int i = 0; i<=8;i++)
  81.                 {
  82.                     Hled[i] = 1;
  83.                 }
  84.             }
  85.             else
  86.             {
  87.                 for(int i = 0; i<=8;i++)
  88.                 {
  89.                     Hled[i] = 0;
  90.                 }
  91.             }
  92.  
  93.             c++;
  94.  
  95.         }
  96.         if(!g_but12)
  97.         {
  98.                     if(k % 2 == 0)
  99.                     {
  100.                         for(int i = 0; i<=8;i = i + 2)
  101.                         {
  102.                             Hled[i] = 1;
  103.                         }
  104.                     }
  105.                     else
  106.                     {
  107.                         for(int i = 0; i<=8;i++)
  108.                         {
  109.                             Hled[i] = 0;
  110.                         }
  111.                     }
  112.  
  113.                     k++;
  114.  
  115.         }
  116.  
  117.  
  118.     }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement