如何通过两个NRF24L01连接2个arduinos [英] How do I connect 2 arduinos via two NRF24L01

查看:161
本文介绍了如何通过两个NRF24L01连接2个arduinos的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,



我写了一个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?

推荐答案

据我所知,您必须使用特定的库才能从这些设备中获取有意义的数据。在此页面上有一个llok nRF24L01 [ ^ ]。
As far as I know you have to use a specific library in order to obtain meaningful data from such devices. Have a llok at this page "nRF24L01"[^].


这篇关于如何通过两个NRF24L01连接2个arduinos的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆