int led = 13;                
int sensorPIR = 8;               
int pirState = LOW;// Iniciamos asumiendo que no hay movimiento alguno
int val = 0;                    
////////////////////////////////////////////////////////////////////VOID SETUP
void setup() {
  pinMode(led, OUTPUT);      
  pinMode(sensorPIR, INPUT);     
  Serial.begin(9600);
}
////////////////////////////////////////////////////////////////////VOID LOOP
void loop(){
  val = digitalRead(sensorPIR);
 
  if (val == HIGH) {            
  digitalWrite(led, HIGH);  
  if (pirState == LOW) {
  Serial.println("Objeto detectado!");
  pirState = HIGH;
  }
  }
  else {
  digitalWrite(led, LOW);
  if (pirState == HIGH){
  Serial.println("-");
  pirState = LOW;
  }
  }
  }

News Flash

Responsive Joomla template JA Purity III marks the next milestone of us in crafting the best Joomla templates for our techie users. Following up with Purity series, JA Purity III heritages the outstanding advantages of its pioneers: brilliant adaptation for multi-purpos

Leer más...