Jump to content
43oh

How to send data from msp430 with HC-05


Recommended Posts

Hi,

I have got a hc-05 Bluetooth module, an MSP-EXP430FR4133 board. Now I want to connect them with my computer. However, even I successfully send data from my computer to control the MSP430, it cannot send data back. Can someone tell me what I can do?

Here is my code. By the way, I'm using energia for it and set my HC-05 as a slave module.

_________________________________________________

// most launchpads have a red LED
#define LED RED_LED
//see pins_energia.h for more LED definitions
//#define LED GREEN_LED


 

void setup() {
  Serial.begin(9600); /* Define baud rate for serial communication */
  pinMode(LED, OUTPUT);
}

void loop() {
  
    if (Serial.available()>0)  /* If data is available on serial port */
    {

      char state = Serial.read();  /* Data received from bluetooth */
      if (state == '0')
      {
        digitalWrite(LED, HIGH);
        Serial.write("LED turned ON");  
        state=0;
            
      }
      else if (state == '1')
      {
        digitalWrite(LED, LOW);
        Serial.write("LED turned OFF");
        state=0;
      }
      }

-----------------------------------------------------------------------------------------------------------------------

Waiting for replay!

Thank you

Kelly

Link to post
Share on other sites
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...