How to read back PROGMEM with integer, long and float

Hello

How do you read back (integer, long, float, byte) value stored using PROGMEM?

const int baudrate_[] PROGMEM ={9600};

int abaud = {(baudrate_)};

Serial.print ("abaud: ");
Serial.println(abaud);

The displayed value is: 194

Martin

https://www.arduino.cc/reference/tr/language/variables/utilities/progmem/

http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html

The code you posted doesn't compile, please post the full sketch.

You need the pgm_read_* macros: avr-libc: <avr/pgmspace.h>: Program Space Utilities

Baud rates should be stored as unsigned long, not int.

Pieter

Thanks jremington and PieterP

I did succeed to properly set and read back the value stored with PROGMEM

unsigned long abaud = pgm_read_word_near(baudrate_);
float afull = pgm_read_float_near(full_1);
float empty1 = pgm_read_float_near(emptyCan_ );

Martin

To read an unsigned long, you have to use pgm_read_dword_near.

PieterP:
To read an unsigned long, you have to use pgm_read_dword_near.

Modification done.

Thanks PieterP