之后使用USB线连接底板上的USB接口给其供电。此时热释传感器检测到附近有人后,LED灯会变换颜色,喇叭播放出欢迎语音。并且会根据人来往的方向判断是进门还是出门。
void judge()
{
//先过D4后过D6为进入
if((digitalRead(body_pin) == 1) && (digitalRead(body_pin2) == 0))
{
FLAG_1 = 1;
delay(200);
}
if((digitalRead(body_pin) == 1) && (digitalRead(body_pin2) == 1) && (FLAG_1 == 1))
{
colorWipe(color[random(1, 10)]);
audio_choose(1);
Serial.println("COMING IN");
FLAG_1 = 0;
delay(1300); //1300
}
//先过D46过D4为出门
if((digitalRead(body_pin) == 0) && (digitalRead(body_pin2) == 1))
{
FLAG_2 = 1;
delay(200); //2000
}
if((digitalRead(body_pin) == 1) && (digitalRead(body_pin2) == 1) && (FLAG_2 == 1))
{
colorWipe(color[random(1, 10)]);
audio_choose(2);
Serial.println("GOING OUT");
FLAG_2 = 0;
delay(1300); //2000
}
}