Jump to content
kellyshen

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×