Skip to content

Commit 1d30559

Browse files
authored
Merge pull request #20 from Chris--A/patch-1
Fixed PROGMEM example, and updated for modern IDE.
2 parents d234023 + 70b488e commit 1d30559

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Language/Variables/Utilities/PROGMEM.adoc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Store data in flash (program) memory instead of SRAM. There's a description of t
2222

2323
The `PROGMEM` keyword is a variable modifier, it should be used only with the datatypes defined in pgmspace.h. It tells the compiler "put this information into flash memory", instead of into SRAM, where it would normally go.
2424

25-
PROGMEM is part of the http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html[pgmspace.h] library. So you first need to include the library at the top your sketch, like this:
25+
PROGMEM is part of the http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html[pgmspace.h] library. It is included automatically in modern versions of the IDE, however if you are using an IDE version below 1.0 (2011), you'll first need to include the library at the top your sketch, like this:
2626

2727
`#include <avr/pgmspace.h>`
2828
[%hardbreaks]
@@ -64,9 +64,6 @@ The following code fragments illustrate how to read and write unsigned chars (by
6464

6565
[source,arduino]
6666
----
67-
#include <avr/pgmspace.h>
68-
69-
7067
// save some unsigned ints
7168
const PROGMEM uint16_t charSet[] = { 65000, 32796, 16843, 10, 11234};
7269
@@ -92,7 +89,7 @@ void setup() {
9289
Serial.println();
9390
9491
// read back a char
95-
for (k = 0; k < strlen(signMessage); k++)
92+
for (k = 0; k < strlen_P(signMessage); k++)
9693
{
9794
myChar = pgm_read_byte_near(signMessage + k);
9895
Serial.print(myChar);

0 commit comments

Comments
 (0)