I am trying to read a string of text from text sent from an android phone to a bluesmirf silver mate.
I am using the code below to read a character from the serial and it puts it into a varaiable vl.
I want to send the text to the tft via testdrawtext ... however, if I put a string "info" in place of vl
it works fine but I am having problems sending a letter or number that is vl.
Is there a way to in arduino c to convert vl to a string?
Thank you.
============= code ============================
char vl ;
void loop()
{
vl = bluetooth.read();
testdrawtext(vl, YELLOW);
}
These are the errors I get:
error: invalid conversion from 'int' to 'char*'
error: initializing argument 1 of 'void testdrawtext(char*, uint16_t)'
============================================================
Help with converting char to *char
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- cstratton
- Posts: 294
- Joined: Wed Sep 29, 2010 3:52 pm
Re: Help with converting char to *char
A char* is a pointer to a string or array of char's. Conventionally, a string of this type must be terminated by a null (0) byte.
You can do something like this:
You can do something like this:
Code: Select all
char s[2]; //create an array of two single-byte characters
s[0] = bluetooth.read(); //put single character in first element of array
s[1] = 0; //null terminate
testdrawtext(s, YELLOW); //display the string
Please be positive and constructive with your questions and comments.