#include <Arduino.h>
int sensorpin = 8;
int ledpin = 9;
bool sensorOutput;
void setup() {
Serial.begin(9600);
pinMode(sensorpin, INPUT);
pinMode(ledpin, OUTPUT);
}
void loop() {
sensorOutput = digitalRead(sensorpin);
if(sensorOutput == HIGH){
Serial.println("有人!");
digitalWrite(ledpin, HIGH);
}else{
Serial.println("无人...");
digitalWrite(ledpin, LOW);
}
delay(10);
}