Go Down

Topic: How to read "words" or Char data with the arduino Bluetooth module (Read 165 times) previous topic - next topic


I was trying to program with my Arduino HC-06 Bluetooth module but when I tried to send a "word" the line 27
("mode = Bluet.read();")
sent me an error, saying that the assigments are incompatible, I tried using ("char()") to make a conversion from int to char, but there is still an error.
So if someone could help me I would be complete thankful, I am complete new at Arduino, I just used toprogram in C++ little. Please and Thank you

Code: [Select]

#include <SoftwareSerial.h>        //Include the library

const int led = 13;
const int rele = 2;
int state;
char mode[ ] = "mode";

SoftwareSerial Bluet (11, 10);     //Tx & Rx of Bluetooth module

void setup() {
 pinMode (led, OUTPUT);            //Declare
 pinMode (rele, OUTPUT);
 Serial.begin(9600);               //Declare the Serial
 Bluet.flush();                        //"Start" the Bluetooth module
 delay (500);
 Bluet.begin(9600);                //Declare Bluetooth module speed


void loop() {

 if (Bluet.available() > 0)         //If Bluetooth receive Bytes
  if (mode == "mode"){
  mode = Bluet.read();
  Serial.write(mode);               //Print the value received
  Serial.print ("\r \n");
  state = Bluet.read();
  Serial.print ("\r \n");


 if (mode == "Light"){
 if (state == '0')                  //Then 
 digitalWrite (rele, LOW);

 if (state == '1')
 digitalWrite (rele, HIGH);


Go Up