Advertisement
Guest User

Contador com sensor PIR

a guest
Jan 14th, 2017
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1.         // Leitura sensor presença PIR
  2.        
  3. byte SensorP = A0; // Pino ligado o led e o sensor PIR
  4. int Leitura;               // Faz a leitura se algo passo na frente no sensor
  5. int Contador;              // Conta quantas vezes o sensor for obstruido
  6.  
  7. void setup(){
  8.   Serial.begin (9600);
  9.   pinMode (SensorP, INPUT);// Define o pino do sensor como entrada
  10. }
  11.  
  12. void loop(){
  13.  
  14.   int Valorlido = analogRead (A0);
  15.   if (Valorlido > SensorP){
  16.     Contador = Contador + 1;
  17.     Serial.println (Contador);
  18.   }  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement