how to change readUnsigned from storing numbers to storing letters
void readstring(char str[], char len) {
char index = 0;
while (index < len-1)
{
// if waiting read
while (serial.available()== 0){}
{
char c = serial.read();
// press enter
if (c == '\r')
{
break;
}
else
{
//stores characters array
str[index] = c;
//adds index 1 characters
//ensures when character pressed,
//the character visible in serial-mon instead of 0
index += 1;
serial.print(c);
}
}
}
//marks end of string.
str[index] = '\0';
}
uint8_t readunsigned() {
//an array store 8bit integars
char str[8];
readstring(str,8);
//returns integar
return atol(str);
}
char index = 0;
while (index < len-1)
{
// if waiting read
while (serial.available()== 0){}
{
char c = serial.read();
// press enter
if (c == '\r')
{
break;
}
else
{
//stores characters array
str[index] = c;
//adds index 1 characters
//ensures when character pressed,
//the character visible in serial-mon instead of 0
index += 1;
serial.print(c);
}
}
}
//marks end of string.
str[index] = '\0';
}
uint8_t readunsigned() {
//an array store 8bit integars
char str[8];
readstring(str,8);
//returns integar
return atol(str);
}
what receiving , trying store?
give example.
/mogens
give example.
/mogens
Arduino Forum > Using Arduino > Programming Questions > how to change readUnsigned from storing numbers to storing letters
arduino
Comments
Post a Comment