- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
首先,我是 Arduino 的初学者。我有一个电路,包括:一个 Arduino Uno、一个 RFID RC522 读卡器和一个 RF 433 MHz 模块的发送器。
我正在尝试使用 RF 433MHz 发送器传输 RFID 卡的 ID 代码,但它不起作用。首先,我读取卡片,然后将 RFID 代码组成一个字符串,例如 "18016518623564"
。
使用下面的代码,我无法读取 RFID 卡。 (串行监视器上什么也看不到。)这似乎是 vw_setup(2000);
的问题。如果我注释掉它,我可以阅读一次代码。如果我也注释掉 vw_wait_tx();
,我可以读两遍代码。如果我也注释掉 send("1");
,我可以无限次地阅读代码。但是,无论我做什么,都无法发送(程序停止在 vw_wait_tx();
)。
有人可以帮我解决这个问题,并且能够将 RFID 代码发送给接收者吗?
代码如下:
// includes for RFID
#include <SPI.h>
#include <RFID.h>
// includes for RF communication
#include <VirtualWire.h>
// defines for RFID
#define SS_PIN 10
#define RST_PIN 5
// variables for RFID
RFID rfid(SS_PIN, RST_PIN);
int serNum[5]; // array to store the RFID code
String rfid_string; // variable to store the concatenated card identifier
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.init();
// initialize the IO and ISR for RF
vw_setup(2000); // Bits per sec
}
void loop() {
read_and_compose_rfid_code(); // read and compose the rfid code into one string
send("1"); // send 1 throug RF - just for testing
delay(1000);
}
void read_and_compose_rfid_code (void) {
if (rfid.isCard()) {
// check if rfid card is present nearby to the sensor antenna
if (rfid.readCardSerial()) {
// read card identifier into array defined in RFID class
// concatenate the card identifier as one string
rfid_string = String(rfid.serNum[0]) + String(rfid.serNum[1]) + String(rfid.serNum[2]) + String(rfid.serNum[3]) + String(rfid.serNum[4]);
Serial.print(rfid_string); // test to see if the code is properly composed
Serial.println();
}
rfid.halt();
delay(1000); // set a delay of 1 second before the next card read
}
}
/* function used to send the card identifier through RF */
void send (char *message) {
vw_send((uint8_t *)message, strlen(message));
// "message" is an array of the bytes to send, and strlen(message) is the number of bytes stored in the array
vw_wait_tx(); // wait until the whole message has been transmitted
}
最佳答案
经过多次尝试,我找到了解决方案。
如果我在 SPI 和 rfid 之前初始化 RF (vw_setup(2000);
),我可以读取卡并发送消息。我不知道它为什么有效,但它确实有效。也许有人可以解释。
关于无法使用 Arduino Uno 使用 RF 433 MHz 发射器发送消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38021292/
Unix 中 rm -rf 中的 rf 代表什么? 更一般地说,我很难记住 Unix 命令和选项,因为我不明白它们代表什么。是否有资源可以解释这些简写的含义? 最佳答案 在rm中, -r 代表递归 -
在 Makefile 中,我读到: -rm -rf(而不是 rm -rf)。 Makefile 中行开头的第一个“-”是什么意思? 最佳答案 这意味着make本身将忽略来自rm的任何错误代码。 在 m
rm是删除item,但是参数-rf的作用是什么? 每当我输入 help -rf 时,它都会打印 powershell 中可用命令的完整列表。如果您在 powershell 中输入 rm -rf 会发生
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
我尝试搜索 SO,但无法找到以下命令之间的区别。如果我有一个名为 dir 的目录,下面的命令有何不同? rm -rf dir/* rm -rf dir/ rm -rf dir 另外,如果运行命令的 i
我很困惑,为什么没有交叉验证的随机森林分类模型的平均准确度得分为 0.996,而具有 5 折交叉验证的模型的平均准确度得分为 0.687。 有 275,956 个样本。 0级=217891,1级=60
我正在尝试在 DRF3 中制作一个可写的嵌套序列化器。我有一个模型音乐会,其中有一个 m2m 领域“技术人员”到我的用户模型。我已成功在其 View 中添加连接到 Concert 实例的用户列表。现在
rm -rf 只删除文件不删除文件夹 我有一个数据库,我循环遍历 file_path 并检查 file_exist 如果文件不存在。我执行 rm -rf $db_value 但有时 db_value
首先,这是windows系统,不是linux。在我的 makefile 中,我正在做 make clean rm -rf output 但是,第一次运行时,会报错 rm: cannot lstat `
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我有一个非常简单的 dockerfile,用“rm -Rf”在安装后删除安装文件,但是我收到了一些错误,例如: Step 4/4 : RUN rm -Rf /INSTALLATION ---> Run
我想使用 TCL 删除目录中的所有文件。 (我在 Win 10 下使用 Xilinx Vivado 的 TCL 控制台。)我在 TCL documentation 中发现了这一点。那个 file de
git中的“-rf”是什么意思? 我用了 git rm -rf directories 但我不知道 -rf 的实际含义 最佳答案 -r - 当给出前导目录名称时允许递归删除。 -f - 覆盖最新检查。
当您将其键入控制台并运行时,此命令将完美运行。 rm -rf !(folder1|file_name|log.txt|*.sh|*.conf) 但是,当我从bash脚本运行它时,出现以下错误; ./t
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭10 年前。 Improve th
我的问题与 here 完全相同和 here . 我还使用 simple2.py 对该程序生成的可执行文件进行沙箱处理 test1.c: #include int main(){ puts
使用随机森林算法进行回归,我在 iternet 中发现,在预测之后,它们对预测结果进行归一化,这意味着我们假设结果是 pred pred = pred = pred*(np.exp(-pred/100
我正在尝试编写一个 BASH 脚本,它将递归删除目录中的所有文件。 当我在控制台 rm -rf/home/dir/dir/* 中写入时,效果很好,但我不能使用变量来完成。 VAR="/home/dir
我是一名优秀的程序员,十分优秀!