代码
/*!
* MindPlus
* uno
*
*/
#include <DFRobot_URM10.h>
#include <DFRobot_Libraries.h>
#include <DFRobot_LiquidCrystal_I2C.h>
// 动态变量
volatile float mind_n_KaiGuanCiShu;
// 创建对象
DFRobot_LiquidCrystal_I2C lcd1602;
DFRobot_URM10 urm10;
DFRobot_Sharp sharp;
// 主程序开始
void setup() {
Serial.begin(9600);
lcd1602.begin(0x3E);
mind_n_KaiGuanCiShu = 0;
}
void loop() {
Serial.println(analogRead(A0));
Serial.println((urm10.getDistanceCM(4, 5)));
if ((digitalRead(13)==1)) {
mind_n_KaiGuanCiShu += 1;
delay(200);
}
if ((((int32_t(mind_n_KaiGuanCiShu)) % (int32_t(2)))==1)) {
// 陷阱代码
if ((((digitalRead(9) || digitalRead(11)) || digitalRead(7)) || (sharp.distanceMm(A0)<10))) {
digitalWrite(8, HIGH);
lcd1602.printLine(uint32_t(1), "fail");
digitalWrite(3, HIGH);
}
else {
digitalWrite(8, LOW);
lcd1602.clear();
digitalWrite(3, LOW);
}
if (((urm10.getDistanceCM(4, 5))<10)) {
lcd1602.printLine(uint32_t(1), "victory");
}
}
}
评论