Thursday, September 12, 2019

HM-TRLR-D-868 WITH ARDUINO MEGA

HM-TRLR-D-868 COMMUNICATION WITH ARDUINO  MEGA 2560






SENDER SIDE CODE EXAMPLE

//char incomingByte = 0; // for incoming serial data
int cntr = 1;

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
  Serial.print("sender\n");
}

void loop() {

  if(Serial.available()> 0)
  {
    //Serial.print("receving::");
    //Serial.println(Serial.read());
    //delay(1000);
    //Serial.print("sending:");
    Serial.println("1234");
    //Serial.write(cntr);
    // Serial.print("\n");
    cntr++;
    //delay(1000);
  }
  else
  {
      Serial.print("0\n");
  }
  delay(1000);



RECEIVER SIDE CODE EXAMPLE

//int counter = 1;

void setup()
{
  Serial.begin(9600);
   Serial1.begin(9600);
  Serial.print("receiver\n");
}

void loop()
{

  if(Serial.available() > 0)
  {
    //int incomingbytes = Serial.read();
    //Serial.print("counter");
   // Serial.write("counter::");
    ///Serial.write(counter);
    //Serial.write(1);
    delay(1000);
    Serial.print("receving::");
   
    //Serial.println(incomingbytes,DEC);
    Serial.print((char)Serial.read());
    Serial.print("\n");
   
    //counter++;
  }
  else
  {
      Serial.print("not available\n");
  }
     
  delay(1000);

}


CONNECTIONS WITH ARDUINO MEGA

ARDUINO MEGA 2560 WITH HM-TRLR-D-868:
Hm-TRLR_868
ARDUINO MEGA 2560
5V
5V
GND
GND
TX
RX
RX
TX
Gnd
Gnd
Sleep
gnd



No comments:

Post a Comment

python class topic video