Can anyone confirm this for me although I have tested it myself but when I send a string of data from my android app and send it to arduino say for example data = bluetoothPort.read();
inside an if statement then when I try to use the data
in another if statement for example Serial.print(data);
inside another if statement it will only show a blank line which let me believe that none of the data are saved. also when a receiving a string of data for example a string of abcde and send it to arduino for example data = bluetoothport.read()
and then Serial.print(data)
the serial monitor shows abcde as expected but what really happens is data has the value of a then prints then replace by b then print then replace by c then print then replace by d then print then replace by e. Am I wrong or somehow right? are there any work around or parts I need that will make me store data as a whole so that I can use it for other thread or a better code to store string of data?
#include <IRremote.h>
#include <SoftwareSerial.h>
SoftwareSerial bluetoothPort(4,5);
const int RECV_PIN = 12;
const int SEND_PIN = 13;
IRsend irsend;
IRrecv irrecv(RECV_PIN);
decode_results results;
char data;
void setup()
{
bluetoothPort.begin(9600);
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop()
{
if (bluetoothPort.available() > 0)
{
data = bluetoothPort.read(); //received bluetooth data from android
}
if(irrecv.decode(&results))
{
irreceived(); //received IR code from a remote then sends it to my android
irsend.sendNEC(data, 32)
}
}
void irreceived()
{
Serial.println(results.value, HEX); //receive value of 489010
bluetoothPort.println(results.value, HEX); //send value to android
irrecv.resume();
}
so the above is a simple sketch that receive data from a remote controller then send it to my android app then when I resend it back to my arduino I would like the data to be able to receive all the data instead of saving it per letter/number and also be able to store it for other statement to use.