talkie.h error

hi guys,

attempting to add the talking function for my robot.

running a sketch using talkie.h
runs into this error. occurs with each sketch under examples
of talkie.h

uint8_t spah PROGMEM = {0x2d,0xa0,0xdd,0x48,0xdb,......................,0xc4,0x7e};

^

exit status 1
variable 'spah' must be const in order to be put into read-only section by means of 'attribute((progmem))'

below is the code of sketch.

A very simple code that says "Ah, that's better." using the
Talkie library and an amplifier and speaker connected to pin 3
and to ground.
*/

#include "talkie.h"

Talkie voice;

/* the data that says "Ah, that's better." */
uint8_t spah PROGMEM = {0x2d,0xa0,0xdd,0x48,0xdb,0xc2,0xac,0xd8,0x2e,0x11,0x75,0x0f,0x72,0x12,0xd7,0xc3,0xd9,0xbc,0xf0,0xcd,0x4e,0xe1,0x7b,0x24,0x69,0x16,0x0e,0x40,0x68,0x51,0x11,0x08,0x40,0xa8,0x51,0x1e,0x30,0x80,0x6f,0x9e,0x83,0xf3,0xdd,0x83,0xc5,0x0b,0x37,0xde,0x2d,0x13,0x35,0x0f,0x5c,0xbd,0xe4,0xe9,0xe1,0x24,0x29,0x81,0x93,0x2f,0x4a,0x90,0x98,0x14,0x76,0x3d,0xf0,0xa1,0xaa,0x32,0x19,0x01,0xdc,0xaa,0x31,0x53,0x07,0x35,0x55,0x0b,0x8c,0x3c,0xe0,0xdc,0xcd,0x2d,0x12,0xca,0x81,0x2d,0xf7,0xb4,0x58,0xa8,0x01,0x2e,0xcc,0xd4,0x13,0x39,0x9f,0xd7,0x30,0x37,0x35,0xb2,0x52,0xd9,0x5d,0xc3,0xc4,0xc8,0xc9,0x54,0xf7,0x34,0x71,0x21,0x27,0x93,0x43,0xcb,0xdd,0x88,0x96,0x82,0x6d,0x29,0x67,0x25,0x66,0x4a,0xb6,0xd5,0x5d,0x44,0xa8,0x2b,0x4d,0xa8,0xf4,0x34,0x53,0x29,0x6b,0xc6,0xdc,0xd4,0x22,0x17,0xd7,0x53,0xf7,0x48,0x6f,0xac,0x38,0xa0,0x23,0xbc,0xdc,0x12,0xe9,0x85,0x70,0xb7,0xb4,0x48,0xc6,0x81,0xcd,0x2a,0x4d,0x2d,0xb7,0x14,0xe6,0xe2,0x08,0x8c,0x32,0x72,0xd1,0xd4,0x5b,0x59,0xe8,0x28,0x75,0xa5,0x4a,0x13,0xa1,0xa5,0x61,0x4d,0x3c,0x4d,0x84,0xa6,0x8e,0x3a,0x49,0x0b,0x37,0x9d,0x58,0xd6,0x69,0xc4,0x59,0x72,0x62,0x6c,0x85,0xd3,0x60,0xc9,0x81,0xd5,0x0d,0x4e,0x8c,0xc5,0x46,0xde,0x34,0xa0,0xc0,0x96,0x4a,0x14,0xd5,0xb3,0x04,0xd9,0x26,0x51,0x44,0x1f,0x32,0x70,0x05,0x47,0x15,0x65,0x08,0x0c,0x52,0x92,0x84,0xc4,0x21,0xa0,0x58,0xa8,0x5d,0x92,0x68,0x27,0x48,0xa3,0x71,0x48,0x8e,0x8d,0x12,0x6f,0xc4,0x7e};

void setup()
{
voice.say(spah); /* say "Ah, that's better." */
}

void loop()
{
}

how do I overcome this error - what needs to be done as I have
followed to the letter under instructions.

sunil v

Is there something about this:

variable 'spah' must be const in order to be put into read-only section by means of 'attribute((progmem))'

that isn't crystal clear?

Have you searched this site for this oft-posted error message and the dirt-simple fix?

Hint: It involves adding the const keyword to the line, just like the message says.

thx pauls.

I presume you suggest to add const spah?

still I get the error - you may try yourself.
or am I not following you.

no sketch publish on Arduino area had any errors up to now.

#include "talkie.h"

Talkie voice;

const int spah;

/* the data that says "Ah, that's better." */
uint8_t spah PROGMEM =

sunilv

Now you have two variables called spah.

Remove what you added and add the const keyword to the original declaration of spah.

And read the PROGMEM reference.

thx sterretje and paul,

yes defined the spah as a const int. (I really don't know why a const need to be defined,
its the programmer's wish to define a variable or a constant - const int seems superfluous)

however, I use a buzzer - doesn't seem to work with that. you can verify yourself.
I am stumped. i want to really exploit the buzzer.

final code - tone works but not spah.

/*
A very simple code that says "Ah, that's better." using the
Talkie library and an amplifier and speaker connected to pin 3
and to ground.
*/

#include "talkie.h"

Talkie voice;

int say = 21; // buzzer

/* the data that says "Ah, that's better." */

const uint8_t spah PROGMEM = {0x2d,0xa0,0xdd,0x48,0xdb,0xc2,0xac,0xd8,0x2e,0x11,0x75,0x0f,0x72,0x12,0xd7,0xc3,0xd9,0xbc,0xf0,0xcd,0x4e,0xe1,0x7b,0x24,0x69,0x16,0x0e,0x40,0x68,0x51,0x11,0x08,0x40,0xa8,0x51,0x1e,0x30,0x80,0x6f,0x9e,0x83,0xf3,0xdd,0x83,0xc5,0x0b,0x37,0xde,0x2d,0x13,0x35,0x0f,0x5c,0xbd,0xe4,0xe9,0xe1,0x24,0x29,0x81,0x93,0x2f,0x4a,0x90,0x98,0x14,0x76,0x3d,0xf0,0xa1,0xaa,0x32,0x19,0x01,0xdc,0xaa,0x31,0x53,0x07,0x35,0x55,0x0b,0x8c,0x3c,0xe0,0xdc,0xcd,0x2d,0x12,0xca,0x81,0x2d,0xf7,0xb4,0x58,0xa8,0x01,0x2e,0xcc,0xd4,0x13,0x39,0x9f,0xd7,0x30,0x37,0x35,0xb2,0x52,0xd9,0x5d,0xc3,0xc4,0xc8,0xc9,0x54,0xf7,0x34,0x71,0x21,0x27,0x93,0x43,0xcb,0xdd,0x88,0x96,0x82,0x6d,0x29,0x67,0x25,0x66,0x4a,0xb6,0xd5,0x5d,0x44,0xa8,0x2b,0x4d,0xa8,0xf4,0x34,0x53,0x29,0x6b,0xc6,0xdc,0xd4,0x22,0x17,0xd7,0x53,0xf7,0x48,0x6f,0xac,0x38,0xa0,0x23,0xbc,0xdc,0x12,0xe9,0x85,0x70,0xb7,0xb4,0x48,0xc6,0x81,0xcd,0x2a,0x4d,0x2d,0xb7,0x14,0xe6,0xe2,0x08,0x8c,0x32,0x72,0xd1,0xd4,0x5b,0x59,0xe8,0x28,0x75,0xa5,0x4a,0x13,0xa1,0xa5,0x61,0x4d,0x3c,0x4d,0x84,0xa6,0x8e,0x3a,0x49,0x0b,0x37,0x9d,0x58,0xd6,0x69,0xc4,0x59,0x72,0x62,0x6c,0x85,0xd3,0x60,0xc9,0x81,0xd5,0x0d,0x4e,0x8c,0xc5,0x46,0xde,0x34,0xa0,0xc0,0x96,0x4a,0x14,0xd5,0xb3,0x04,0xd9,0x26,0x51,0x44,0x1f,0x32,0x70,0x05,0x47,0x15,0x65,0x08,0x0c,0x52,0x92,0x84,0xc4,0x21,0xa0,0x58,0xa8,0x5d,0x92,0x68,0x27,0x48,0xa3,0x71,0x48,0x8e,0x8d,0x12,0x6f,0xc4,0x7e};

void setup()
{
pinMode(say, OUTPUT);
voice.say(spah); /* say "Ah, that's better." */

}

void loop()
{

voice.say(spah);

noTone(11);
tone(say, 440, 200); // Send 1KHz sound signal...
delay(100); // ...for 1 sec

}

thx for you both.

sunil v

int say = 21; // buzzer

I don't understand this statement or comment. Perhaps because I consistently use pin in the names of variables that hold pin numbers. Is this a pin number?

You should post a link to the talkie library. Perhaps there are some non-obvious requirements for the pin that can be used.

SunilV:
yes defined the spah as a const int. (I really don't know why a const need to be defined,
its the programmer's wish to define a variable or a constant - const int seems superfluous)

It's just how it is; anyway, as PROGMEM (flash) variables can't be changed, there is no reason not to make them const.

thx paul and sterretje,

yes 21 is a pin number, used with tone() function to emit the noise in buzzer.

with setup - voice.say(spah); const spah should be linked
and the buzzer should be activated in loop;

  • which seems not happening.

as per suggestion had a look in talkie library.

and a hint was -

““Talkie sets up a special very high speed PWM, so audio can be taken directly from pin 3 with no other filtering””. tried pin 3 instead of 21 - no luck.
maybe buzzer cannot be used with talkie.

maybe buzzer cannot be used with talkie.

That would seem to be a reasonable conclusion. Perhaps the buzzer simply can not vibrate fast enough.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

What model Arduino are you using?

Thanks… Tom… :slight_smile:

thx all.

TomGeorge - I am not into cad or drawing pics, a photo would not help at all,
wiring is a bit messy - so sorry.

confined to talkie.h, it's a simple circuit on Arduino Mega 2560.
I have pinned the buzzer to 3, + to 5v and - to gnd.

I may have to go for a better system - amp/speaker.

sunil bv

Hi,

I am not into cad or drawing pics,

Well how did you know how to wire your project up.

Get a pen/pencil an paper and draw a diagram and take a picture of it and post it.

You are now in troubleshooting mode, and it is not necessarily, for some people, an enjoyable exercise.

The minute you start checking your wiring, start to draw a circuit.

If you want to do more electronics experimenting or designing you have to be able to draw circuits.

Hand drawn is at the start the best as all the component outlines are in your pen.

Where did you get the "talk.h" library from?
Link please.

Buzzers, buzz, putting tone on a buzzer won't work properly if at all.
try using

digitalWrite(say, HIGH);
delay(500);
digitalWrite(say,LOW);

Tom... :slight_smile: