Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <msp430x14x.h>
  2. int btn1pressed()
  3. {
  4. if(P4IN == 0x10)
  5. {
  6. return 1;
  7. }
  8. else
  9. {
  10. return 0;
  11. }
  12. }
  13.  
  14. int btn2pressed()
  15. {
  16. if(P4IN == 0x20)
  17. {
  18. return 1;
  19. }
  20. else
  21. {
  22. return 0;
  23. }
  24. }
  25.  
  26. int btn3pressed()
  27. {
  28. if(P4IN == 0x40)
  29. {
  30. return 1;
  31. }
  32. else
  33. {
  34. return 0;
  35. }
  36. }
  37.  
  38. int btn4pressed()
  39. {
  40. if(P4IN == 0x80)
  41. {
  42. return 1;
  43. }
  44. else
  45. {
  46. return 0;
  47. }
  48. }
  49.  
  50. void delay(int x)
  51. {
  52. int count;
  53. for (count = 0; count < x; count++);
  54. }
  55.  
  56. void main()
  57. {
  58. WDTCTL = WDTPW + WDTHOLD;
  59. P4DIR=12;
  60. while(1)
  61. {
  62. if(btn1pressed())
  63. {
  64. delay(400);
  65. }
  66. if(btn2pressed())
  67. {
  68. delay(500);
  69. }
  70. if(btn3pressed())
  71. {
  72. delay(600);
  73. }
  74. if(btn4pressed())
  75. {
  76. delay(700);
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement