Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1.  
  2.  
  3. const int cirkel = 13; // the number of the pushbutton pin
  4. const int triangel = 11;
  5. const int rektangel = 6;
  6. const int kvadrat = 3;
  7. const int oval = 5;
  8. const int star = 10;
  9. const int hexagon = 4;
  10. const int heart = 5;
  11. const int romb = 9;
  12. const int piezo = 12; // the number of the LED pin
  13.  
  14. // variables will change:
  15. int buttonState = 0; // variable for reading the pushbutton status
  16. int lastButtonState = LOW;
  17.  
  18. void setup() {
  19. // initialize the LED pin as an output:
  20. pinMode(piezo, OUTPUT);
  21. // initialize the pushbutton pin as an input:
  22. pinMode(cirkel, INPUT);
  23. pinMode(kvadrat, INPUT);
  24. pinMode(hexagon, INPUT);
  25. pinMode(triangel, INPUT);
  26. pinMode(oval, INPUT);
  27. pinMode(heart, INPUT);
  28. pinMode(rektangel, INPUT);
  29. pinMode(star, INPUT);
  30. pinMode(romb, INPUT);
  31.  
  32. }
  33.  
  34. void loop() {
  35. // read the state of the pushbutton value:
  36.  
  37. buttonState = digitalRead(kvadrat);
  38.  
  39. if (buttonState == HIGH) {
  40. // turn LED on:
  41. digitalWrite(piezo, HIGH);
  42. delayMicroseconds(1200);
  43. digitalWrite(piezo, LOW);
  44. delayMicroseconds(1200);
  45. } else {
  46. // turn LED off:
  47. digitalWrite(piezo, LOW);
  48. }
  49.  
  50. buttonState = digitalRead(cirkel);
  51.  
  52. // check if the pushbutton is pressed.
  53. // if it is, the buttonState is HIGH:
  54. if (buttonState == HIGH) {
  55. // turn LED on:
  56. digitalWrite(piezo, HIGH);
  57. delayMicroseconds(1200);
  58. digitalWrite(piezo, LOW);
  59. delayMicroseconds(1200);
  60. } else {
  61. // turn LED off:
  62. digitalWrite(piezo, LOW);
  63. }
  64.  
  65.  
  66. buttonState = digitalRead(hexagon);
  67.  
  68. // check if the pushbutton is pressed.
  69. // if it is, the buttonState is HIGH:
  70. if (buttonState == HIGH) {
  71. // turn LED on:
  72. digitalWrite(piezo, HIGH);
  73. delayMicroseconds(1200);
  74. digitalWrite(piezo, LOW);
  75. delayMicroseconds(1200);
  76. } else {
  77. // turn LED off:
  78. digitalWrite(piezo, LOW);
  79. }
  80.  
  81. buttonState = digitalRead(triangel);
  82.  
  83. // check if the pushbutton is pressed.
  84. // if it is, the buttonState is HIGH:
  85. if (buttonState == HIGH) {
  86. // turn LED on:
  87. digitalWrite(piezo, HIGH);
  88. delayMicroseconds(1200);
  89. digitalWrite(piezo, LOW);
  90. delayMicroseconds(1200);
  91. } else {
  92. // turn LED off:
  93. digitalWrite(piezo, LOW);
  94. }
  95.  
  96. buttonState = digitalRead(heart);
  97.  
  98. // check if the pushbutton is pressed.
  99. // if it is, the buttonState is HIGH:
  100. if (buttonState == HIGH) {
  101. // turn LED on:
  102. digitalWrite(piezo, HIGH);
  103. delayMicroseconds(1200);
  104. digitalWrite(piezo, LOW);
  105. delayMicroseconds(1200);
  106. } else {
  107. // turn LED off:
  108. digitalWrite(piezo, LOW);
  109. }
  110.  
  111. buttonState = digitalRead(rektangel);
  112.  
  113. // check if the pushbutton is pressed.
  114. // if it is, the buttonState is HIGH:
  115. if (buttonState == HIGH) {
  116. // turn LED on:
  117. digitalWrite(piezo, HIGH);
  118. delayMicroseconds(1200);
  119. digitalWrite(piezo, LOW);
  120. delayMicroseconds(1200);
  121. } else {
  122. // turn LED off:
  123. digitalWrite(piezo, LOW);
  124. }
  125.  
  126.  
  127. buttonState = digitalRead(star);
  128.  
  129. // check if the pushbutton is pressed.
  130. // if it is, the buttonState is HIGH:
  131. if (buttonState == HIGH) {
  132. // turn LED on:
  133. digitalWrite(piezo, HIGH);
  134. delayMicroseconds(1200);
  135. digitalWrite(piezo, LOW);
  136. delayMicroseconds(1200);
  137. } else {
  138. // turn LED off:
  139. digitalWrite(piezo, LOW);
  140. }
  141.  
  142. buttonState = digitalRead(romb);
  143.  
  144. // check if the pushbutton is pressed.
  145. // if it is, the buttonState is HIGH:
  146. if (buttonState == HIGH) {
  147. // turn LED on:
  148. digitalWrite(piezo, HIGH);
  149. delayMicroseconds(1200);
  150. digitalWrite(piezo, LOW);
  151. delayMicroseconds(1200);
  152. } else {
  153. // turn LED off:
  154. digitalWrite(piezo, LOW);
  155. }
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement