用Tinkercad学arduino之 人体红外检测报警 LCD显示

项目地址:https://www.tinkercad.com/things/cz2cdSN3EFS-pir-sensor-with-lcd-display

#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,7,6,5,4);

void setup()
{
  Serial.begin(9600);
  lcd.begin(16,2);
  pinMode(8,INPUT);
  
}

void loop()
{
  int a = digitalRead(8);
  Serial.println(a);
  
  if(a==1)
  {
  lcd.setCursor(2,0);
  lcd.print("Thief Detected");
  delay(2000);
  lcd.clear();
  }
  else
  {
  
  }
}

 

posted @ 2020-12-03 17:27  meetrice  阅读(58)  评论(0编辑  收藏