lua - Lua ESP8266 脚本期待额外 =
问题描述
我正在尝试用我的 ESP8266 测试接近传感器,但是我使用的测试代码一直失败。每当我运行代码时,都会出现错误:motion sensor.lua:1: '=' expected near 'int'
我还应该提到我正在使用 ESPlorer v0.2.0
const int PIRSensorOutPin = 2; //PIR Sensor OUT Pin
void setup() {
Serial.begin(9600);
pinMode(PIRSensorOutPin, INPUT);
}
void loop()
{
if (digitalRead(PIRSensorOutPin) == LOW)
{
Serial.println("Person detected!"); //Print to serial monitor
}
else {;}
}
我究竟做错了什么?
解决方案
Lua 解释器不理解 C++。
您正在运行运行 Lua 文件的 NodeMCU 固件。但是您正在尝试运行 Arduino C++ 代码。那是行不通的。要运行此代码,您必须将 ESP8266 支持添加到您的 Arduino IDE,编译您的代码并将其闪存到 ESP。
或者在 Lua 中编写代码。
推荐阅读
- javascript - 当使用“nightwatch-api”上下文/客户端调用时,.elements 在黄瓜的 Given/Then 步骤方法中不起作用
- r - 根据列表名称列表重命名列表列表的第一列
- python-3.x - 在Python中返回包含两个元素的列表中另一个元素的快速方法
- rust - Rust 中未解决的导入。找不到箱子
- javascript - 如何将 ScrollView 中的无限内容与 React-Native 对齐?
- java - 我正在尝试读取文本文件并将其存储在对象数组列表中
- cypress - 如何从赛普拉斯的 react-date-picker 中选择或添加日期?
- r - “条件”列不存在。即使该列显然存在?
- google-maps - 中国支持谷歌地图
- python - 创建一个函数来处理学生成绩的 .txt 文件