hi all, I am probably missing something very obvious but I have a problem I can't seem to fix.
this code produces strange results :
const char PROGMEM string_to_print[] = " I would like to print this string";
void setup()
{
Serial.begin(115200);
Serial.print("Jow");
Serial.println(string_to_print);
}
void loop()
{
}
Serial monitor prints this :
Jow? ? ? ? ? ? ? ? ? ? ? ? ? (a group of 8 and a group of 5 question marks)
Kevin77:
I thought it worked just like using Serial.print(F("a string");
It pretty much does, but you need to cast the pointer type:
const char PROGMEM string_to_print[] = " I would like to print this string";
void setup()
{
Serial.begin(115200);
delay(2000);
Serial.print("Jow");
Serial.println((__FlashStringHelper *)string_to_print);
}
void loop()
{}
Or can you point me to a place I can read up on this?
Find where you installed the Arduino package, then
hardware/arduino/avr/cores/arduino/Print.h
hardware/arduino/avr/cores/arduino/WString.h
hardware/arduino/avr/cores/arduino/Print.cpp
hardware/arduino/avr/cores/arduino/WString.cpp
AWOL:
Find where you installed the Arduino package, then
hardware/arduino/avr/cores/arduino/Print.h
hardware/arduino/avr/cores/arduino/WString.h
hardware/arduino/avr/cores/arduino/Print.cpp
hardware/arduino/avr/cores/arduino/WString.cpp