Advertisement
Rauthag

LED pocet rozsvietenych UTOROK

Sep 17th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1.  
  2. #include "mbed.h"
  3.  
  4. void demo_leds();
  5. void demo_lcd();
  6. void demo_i2c();
  7.  
  8. // DO NOT REMOVE OR RENAME FOLLOWING GLOBAL VARIABLES!!
  9.  
  10. // Serial line for printf output
  11. Serial g_pc(USBTX, USBRX);
  12.  
  13. // LEDs on K64F-KIT - instances of class DigitalOut
  14. DigitalOut g_led1(PTA1);
  15. DigitalOut g_led2(PTA2);
  16.  
  17. DigitalOut ledArray [8] = {
  18. DigitalOut (PTC0),
  19. DigitalOut (PTC1),
  20. DigitalOut (PTC2),
  21. DigitalOut (PTC3),
  22. DigitalOut (PTC4),
  23. DigitalOut (PTC5),
  24. DigitalOut (PTC7),
  25. DigitalOut (PTC8),
  26. };
  27.  
  28. // Buttons on K64F-KIT - instances of class DigitalIn
  29. DigitalIn g_but9(PTC9);
  30. DigitalIn g_but10(PTC10);
  31. DigitalIn g_but11(PTC11);
  32. DigitalIn g_but12(PTC12);
  33.  
  34.  
  35. int main()
  36. {
  37. // Serial line initialization
  38. g_pc.baud(115200);
  39.  
  40. g_pc.printf( "Demo program started...\r\n" );
  41.  
  42. int count = 0;
  43. int buttCount = 0;
  44.  
  45. while (1)
  46. {
  47. wait_ms(250); // delay
  48.  
  49. if(!g_but9){
  50. count++;
  51. //g_pc.printf("%d\n", count);
  52. wait_ms(500);
  53. }
  54.  
  55. for (int i = 7; i>=0; i--){
  56. if (i>7-count){
  57. ledArray[i]=true;
  58. }
  59. else{
  60. ledArray[i]=false;}
  61. }
  62.  
  63.  
  64.  
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement