3
In a program for Arduino, I have an array of strings but it seems that the function where I will use this data only accepts string. How do I convert an array to a string ?
File prog = SD.open("prog.bin");
String leiaS(void){
return String(prog.read());
}
digitalWrite(leia(), inverte(leiaS()));
String inverte(String port){
if(digitalRead(port)==HIGH)
return LOW;
else
return HIGH;
}
Error:
could not Convert leias from 'String (*)()' to 'String'
I realized I was missing a parenthesis in the function call leiaS
. After fixing and checking appeared the error:
cannot Convert 'String' to 'uint8_t {aka unsigned char}' for argument '2' to 'void digitalWrite(uint8_t, uint8_t)'
From what I have researched, there is no ready function. I would go from
loop
inside the array and concatenates a string itself.– Felipe Douradinho
Yes, but for that I believe I would need to know the size of the array. I know it has 1 byte, because the read() function reads 1 byte at a time. The problem is how much this will be in strings. According to the documentation the function sizeof() returns the number of bytes. I do not know if it serves. If you could exemplify.
– Carlos
Carlos, you’re wearing it
String
where one expects numerals, it seems to me that you need to rewrite all your code to get the result you want.– Delfino