Advertisement
RuiViana

Teste1

Feb 12th, 2020
536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1. #define buzzer 7
  2.  
  3. #define pinSensorUM  4
  4. #define pinSensorDOIS 3
  5. #define pinSensorTRES  8
  6. #define pinLedVm  6
  7. #define pinLedAz  5
  8.  
  9. int estadoUM; // variavel que guarda  o estado do sensor
  10. int estadoDOIS;
  11. int estadoTRES;
  12.  
  13. unsigned long instanteUM = 0;    // tempo total decorrido desde que o programa foi executado
  14. unsigned long instanteDOIS = 0;
  15. unsigned long instanteTRES = 0;
  16.  
  17. unsigned long elapsedTimeOne;    // tempo decorrido do primeiro intervalo
  18. unsigned long elapsedTimeTwo;    // tempo decorrido do segundo intervalo
  19. unsigned long tempoTotal;
  20. unsigned long tempoIndica;
  21. int passou = 0;
  22. //‐---------------------------------‐--------------------------------------------
  23. void setup() {
  24.  
  25.       Serial.begin (9600);
  26.       pinMode(pinLedVm,OUTPUT);
  27.       pinMode(pinLedAz,OUTPUT);
  28.       pinMode(buzzer,OUTPUT);
  29.       pinMode(pinSensorUM, INPUT);
  30.       pinMode(pinSensorDOIS, INPUT);
  31.       pinMode(pinSensorTRES, INPUT);
  32.    
  33.      digitalWrite (pinLedVm,LOW);   // desliga LED vermelho
  34.      digitalWrite (pinLedAz,LOW);      // desliga LED verde
  35.      digitalWrite (buzzer,LOW);
  36. }
  37. //‐---------------------------------‐--------------------------------------------
  38. void loop()
  39. {
  40.   estadoUM = digitalRead(pinSensorUM); // ler o pinSensor1 e armazena em estado
  41.   if (estadoUM == LOW)
  42.   {
  43.       Serial.print("Sensor1 ");
  44.       Serial.println(millis());
  45.   }
  46.        
  47.   estadoDOIS = digitalRead(pinSensorDOIS); // ler o pinSensor1 e armazena em estado
  48.   if (estadoDOIS == LOW)
  49.   {
  50.       Serial.print("Sensor2 ");
  51.       Serial.println(millis());
  52.   }
  53.  
  54.   estadoTRES = digitalRead (pinSensorTRES);
  55.   if (estadoTRES == LOW)
  56.   {
  57.       Serial.print("Sensor3  ");
  58.       Serial.println(millis());
  59.   }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement