问题描述
问候,
我写了一个c#mini程序,通过com端口向arduino1发送0-1信号。我找到了一些关于NRF24L01的库,但是当你在arduino软件上写一些数字或单词时,它们几乎都可以工作。所有我需要的是通过arduino 1打开arduino2上的绿色和红色LED。arduino 1与我的软件进行通信,根据软件,我想打开arduino 2上的LED。
当我使用单个arduino时,这是我的工作代码;
Greetings,
I write a c# mini program that sends 0-1 signal to arduino1 via com port. I found some libraries about NRF24L01 but almost all of them works when you write some numbers or words on arduino software. All i need is turn on green and red leds on arduino2 through arduino 1. arduino 1 communicates with my software and according to software i want to turn on leds on arduino 2.
this is my working code when i work with single arduino;
#define BaudRate 9600
char incomingOption;
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
Serial.begin(BaudRate);
}
void loop()
{
incomingOption = Serial.read();
switch(incomingOption){
case '1':
// Turn ON GREEN LED
digitalWrite(2, HIGH);
delay(5000);
digitalWrite(2, LOW);
break;
case '0':
// Turn ON RED LED
digitalWrite(3, HIGH);
delay(5000);
digitalWrite(3, LOW);
break;
case 'OFF':
digitalWrite(2, LOW);
digitalWrite(3, LOW);
break;
}
}
如何使用nrf24L01为2个arduinos分离此代码?
how do i seperate this code for using nrf24L01 for 2 arduinos?
推荐答案
这篇关于如何通过两个NRF24L01连接2个arduinos的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!