Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. int pinTEMP = A1;
  2. int pinIR = A2;
  3. int pinLIGHT = A3;
  4.  
  5. int TEMP = 0;
  6. int IR = 0;
  7. int LIGHT = 0;
  8.  
  9. int pinLED1 = 11;
  10. int pinLED2 = 10;
  11. int pinLED3 = 9;
  12.  
  13. int pinS1 = 2;
  14. int pinS2 = 3;
  15. int pinS3 = 4;
  16.  
  17. boolean S1 = false;
  18. boolean S2 = false;
  19. boolean S3 = false;
  20.  
  21. void setup() {
  22. Serial.begin(9600);
  23.  
  24. pinMode(pinLED1, OUTPUT);
  25. pinMode(pinLED2, OUTPUT);
  26. pinMode(pinLED3, OUTPUT);
  27.  
  28. pinMode(pinS1, INPUT);
  29. pinMode(pinS2, INPUT);
  30. pinMode(pinS3, INPUT);
  31. }
  32.  
  33. void loop(){
  34. TEMP = analogRead(pinTEMP);
  35. IR = analogRead(pinIR);
  36. LIGHT = analogRead(pinLIGHT);
  37.  
  38. if (digitalRead(pinS1) == LOW) { S1 = !S1;}
  39. if (digitalRead(pinS2) == LOW) { S2 = !S2;}
  40. if (digitalRead(pinS3) == LOW) { S3 = !S3;}
  41.  
  42. delay(500);
  43.  
  44. if (S1) {
  45. analogWrite(pinLED1, TEMP);
  46. Serial.print("T");
  47. Serial.println(TEMP);
  48. } else {
  49. analogWrite(pinLED1, 0);
  50. }
  51.  
  52. if (S2) {
  53. analogWrite(pinLED2, IR);
  54. Serial.print("I");
  55. Serial.println(IR);
  56. } else {
  57. analogWrite(pinLED2, 0);
  58. }
  59.  
  60. if (S3) {
  61. analogWrite(pinLED3, LIGHT);
  62. Serial.print("L");
  63. Serial.println(LIGHT);
  64. } else {
  65. analogWrite(pinLED3, 0);
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement