Advertisement
kmkumar

Untitled

Apr 15th, 2016
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. int led1 = 3;
  2. int led2 = 4;
  3. int led3 = 5;
  4. int led4 = 6;
  5. int led5 = 7;
  6. int led6 = 8;
  7. int led7 = 9;
  8. int led8 = 10;
  9. int BUZZER = 2; // buzzer addressed to the pin 2
  10.  
  11. void setup() {
  12. // initialize serial communication at 9600 bits per second:
  13. pinMode(led1, OUTPUT);
  14. pinMode(led2, OUTPUT);
  15. pinMode(led3, OUTPUT);
  16. pinMode(led4, OUTPUT);
  17. pinMode(led5, OUTPUT);
  18. pinMode(led6, OUTPUT);
  19. pinMode(led7, OUTPUT);
  20. pinMode(led8, OUTPUT);
  21. pinMode(BUZZER, OUTPUT);
  22. Serial.begin(9600);
  23. }
  24.  
  25.  
  26. void loop() {
  27. // read the input on analog pin 1:
  28. int sensorValue1 = analogRead(A0);
  29.  
  30. if (sensorValue1 >=600 && sensorValue1 <=800){
  31. Serial.println(sensorValue1);
  32. digitalWrite(led1, HIGH);
  33. tone(2,392,300); //command tone that creates a sound
  34. }
  35. else {
  36. Serial.println(sensorValue1);
  37. digitalWrite(led1, LOW);
  38. }
  39.  
  40. int sensorValue2 = analogRead(A1);
  41.  
  42. if (sensorValue2 >=600 && sensorValue2 <=800){
  43. Serial.println(sensorValue2);
  44. digitalWrite(led2, HIGH);
  45. tone(2,392,300); //command tone that creates a sound
  46. }
  47. else {
  48. Serial.println(sensorValue2);
  49. digitalWrite(led2, LOW);
  50. }
  51.  
  52. int sensorValue3 = analogRead(A2);
  53.  
  54. if (sensorValue3 >=600 && sensorValue3 <=800){
  55. Serial.println(sensorValue3);
  56. digitalWrite(led3, HIGH);
  57. tone(2,392,300); //command tone that creates a sound
  58. }
  59. else {
  60. Serial.println(sensorValue3);
  61. digitalWrite(led3, LOW);
  62. }
  63.  
  64. int sensorValue4 = analogRead(A3);
  65.  
  66. if (sensorValue4 >=600 && sensorValue4 <=800){
  67. Serial.println(sensorValue4);
  68. digitalWrite(led4, HIGH);
  69. tone(2,392,300); //command tone that creates a sound
  70. }
  71. else {
  72. Serial.println(sensorValue4);
  73. digitalWrite(led4, LOW);
  74. }
  75.  
  76. int sensorValue5 = analogRead(A4);
  77.  
  78. if (sensorValue5 >=600 && sensorValue5 <=800){
  79. Serial.println(sensorValue5);
  80. digitalWrite(led5, HIGH);
  81. tone(2,392,300); //command tone that creates a sound
  82. }
  83. else {
  84. Serial.println(sensorValue5);
  85. digitalWrite(led5, LOW);
  86. }
  87.  
  88. int sensorValue6 = analogRead(A5);
  89.  
  90. if (sensorValue6 >=600 && sensorValue6 <=800){
  91. Serial.println(sensorValue6);
  92. digitalWrite(led6, HIGH);
  93. tone(2,392,300); //command tone that creates a sound
  94. }
  95. else {
  96. Serial.println(sensorValue6);
  97. digitalWrite(led6, LOW);
  98. }
  99.  
  100. int sensorValue7 = analogRead(A6);
  101.  
  102. if (sensorValue7 >=600 && sensorValue7 <=800){
  103. Serial.println(sensorValue7);
  104. digitalWrite(led7, HIGH);
  105. tone(2,392,300); //command tone that creates a sound
  106. }
  107. else {
  108. Serial.println(sensorValue7);
  109. digitalWrite(led7, LOW);
  110. }
  111.  
  112. int sensorValue8 = analogRead(A7);
  113.  
  114. if (sensorValue8 >=600 && sensorValue8 <=800){
  115. Serial.println(sensorValue8);
  116. digitalWrite(led8, HIGH);
  117. tone(2,392,300); //command tone that creates a sound
  118. }
  119. else {
  120. Serial.println(sensorValue8);
  121. digitalWrite(led8, LOW);
  122. }
  123.  
  124. delay(1000);
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement