Battery

Hi

My name is Trevor and am very new to Arduino and now almost nothing about C but am learning.

I need help. My first project is a tiny altimeter which I found on the net and interested me as I am a skydiver. I got all the components and wired them up, but when trying to compile the program I get an error Battery.c:8:9: error: variable 'Battery' must be const in order to be put into read-only section by means of 'attribute((progmem))'
uint8_t Battery[] PROGMEM = { which unfortunately means nothing to me nor can I fix the problem. I would really appreciate help...

We need to see the program to be able to help.

Please put your code in its own window as seen in other posts. This can be done by placing     [code]  and [/code]  around the code or use the </> icon. This makes it easier for others to read.

How to use this forum

Weedpharma

// Battery.c
// Font type    : Battery levels (5 icons)
// Font size    : 20x28 pixels
// Memory usage : 105 bytes

#include <avr/pgmspace.h>

uint8_t Battery[] PROGMEM={
  0x7f, 0xff, 0xf0, 
  0x40, 0x00, 0x10, 
  0xdd, 0xdd, 0xd0, 
  0xdd, 0xdd, 0xd0, 
  0xdd, 0xdd, 0xd0, 
  0x40, 0x00, 0x10, 
  0x7f, 0xff, 0xf0, 
  0x7f, 0xff, 0xf0, 
  0x40, 0x00, 0x10, 
  0xc1, 0xdd, 0xd0, 
  0xc1, 0xdd, 0xd0, 
  0xc1, 0xdd, 0xd0, 
  0x40, 0x00, 0x10, 
  0x7f, 0xff, 0xf0, 
  0x7f, 0xff, 0xf0, 
  0x40, 0x00, 0x10, 
  0xc0, 0x1d, 0xd0, 
  0xc0, 0x1d, 0xd0, 
  0xc0, 0x1d, 0xd0, 
  0x40, 0x00, 0x10, 
  0x7f, 0xff, 0xf0, 
  0x7f, 0xff, 0xf0, 
  0x40, 0x00, 0x10, 
  0xc0, 0x01, 0xd0, 
  0xc0, 0x01, 0xd0, 
  0xc0, 0x01, 0xd0, 
  0x40, 0x00, 0x10, 
  0x7f, 0xff, 0xf0,
  0x7f, 0xff, 0xf0, 
  0x40, 0x00, 0x10, 
  0xc0, 0x00, 0x10, 
  0xc0, 0x00, 0x10, 
  0xc0, 0x00, 0x10, 
  0x40, 0x00, 0x10, 
  0x7f, 0xff, 0xf0
};

The above code is part of a sketch, but when compiling I get the error from the battery tab.

Thanks
Trevor.

Try doing a search (top right hand corner) for 'must be const in order to be put'.

uint8_t Battery[] PROGMEM={

Battery.c:8:9: error: variable 'Battery' must be const

So, why is Battery NOT const? Is the message that difficult to understand?

Sorry very new at this... First time :smiley:

TrevorSA:
Sorry very new at this... First time :smiley:

I'm wondering the same thing... Did You ever find out what was wrong?

kakemanx:
I'm wondering the same thing... Did You ever find out what was wrong?

Heh...yeah, he figured it out in posts #5 and #6. He just needed to add the keyword const before the data defined in PROGMEM.

const uint8_t Battery[] PROGMEM={

Honestly though, if you can't debug that simple of an error you'd do well to sit down with a basic tutorial for C. It'll save time in the long run.