Im working on a project with an Arduino Mega 2560 and a HC-06 Bluetooth module, and I'm using the serial comunication for connecting each other, the deal it's that I'm working with a 'char' variable for reading the serial port, the question is, if I send a number to the serial port from the module to the arduino I'll be able to make operations with it like maping or 'if' instructions? Or what can I make for me to work with the numeric value?
Thanks for your help
When you say that you will be sending a number do you mean a single byte, such as 123 or 3 chars such as "123" ? Either way you can test the value received by the Arduino and act on it. If you want to do something with the number in the second format you can convert the 3 chars into a numeric variable.
For numbers as a single byte you can obvioiusly use
if (numberReceived >= 123)
For a series of chars you can use the strcmp() function
if (strcmp(seriesOfCharsReceived) == "123")
or convert the chars to a number first
aNumber = atoi(seriesOfChars);
then do the normal numeric comparison as above.
This thread may help you in understanding how to receive a series of chars
Serial input basics