[아두이노 부품사용법] 아두이노 호환 nRF24L01 모듈용 ATMega48 개발보드

이노팹 2017-01-16 (월) 23:23 7년전 3233  

개요 (Overview)

 

de573e29eb749648da1c0e59422e3fa8_1484576

NRF24L01 제품을 사용할 때, SPI를 쓰지 않고 I2C를 사용하여 적은 수의 점퍼선으로 아두이노에 연결할 수 있도록 돕는 쉴드입니다. 
 

스펙 (Specification)

  • 70m 송수신 거리

  • 양방향 통신

  • I2C/TWI 프로토콜

  • 아두이노 호환

  • 2.4GHz 

 

사용법 (How to use)

 

두 대의 아두이노에 연결된 개발보드를 준비하고, 개발보드 위에 NRF24L01을 8핀 헤더에 끼웁니다. 이 때, NRF24L01의 방향은 PCB에 새겨진 실크스크린을 통해 확인할 수 있으며, 보드의 바깥쪽으로 길게 끼울 수 있습니다.

de573e29eb749648da1c0e59422e3fa8_1484577
 

 

하드웨어 연결 (Wiring)

 

 de573e29eb749648da1c0e59422e3fa8_1484576 

 

아두이노 코드 (Arduino source code) 

 

마스터/송신부

unsigned char ppt =0; 
#include  
void setup()
{
  Wire.begin();        // I2c Bus (address optional for master)
  Serial.begin(9600);  // Opening Serial Communication for Reading the Output 
}
unsigned char judge = 0,good;

void loop()
{
// Reads Wire Master 
if(judge == 0)
{
      Wire.requestFrom(35, 1);    // Requesting 6 bytes from the slave device #2
      if(Wire.available())
      { 
          good = Wire.read(); // bytes as character
          if(good !=0x47){ 
              //Serial.println(Good) ; // Optional 
              //Serial.println("Receive") ; // Optional 
              judge = 1;
              }
     }
}
// Write Wire Master
if(judge == 1)
{
 Wire.beginTransmission(35); // Send data to device #35
  //Wire.write(7);        // Optional sends 5 bytes
  Wire.write(14Core);              // transfer character 1 save display "14core"
  Wire.endTransmission();    // stop sending
  Serial.println(14Core) ;
  judge = 0;
}
 delay(100); //Delay

}

슬레이브/수신부

#include
void setup()
{
  Wire.begin(); // Bind i2c bus (address is optional for master)
    Serial.begin(9600);  // Opening Serial Communication for reading the output 
}
unsigned char judge = 0;
char scan;
void loop()
{

if(judge == 0)
{
  Wire.beginTransmission(35); // Send to device #35
  //Wire.write(7);        // Optional for testing sends five bytes
  Wire.write(scan); 
  Wire.endTransmission();    // Stop the Transmission 
 judge = 1;
}
 delay(100); 
if(judge == 1)
{
      Wire.requestFrom(35, 1);  // Wire start request 1 byte from the slave module device #35
      if(Wire.available())
      { 
          unsigned char c = Wire.read(); // Receive byte as Character display Say Hello to <a href="http://www.14core.com">www.14core.com</a>
          if(c !=0x47){
            Serial.println(c);
           ++scan; 
           if(scan == 8) scan = 0;  // Scan addresses
            judge = 0; 
           }      
     }  
}
}

.h>.h>

참고 링크 (Links)

 

 

메카리워즈 Image Map


모바일 버전으로 보기