initializer-string for array of chars it too long

Hello everyone,

I am trying to connect a Neurosky Brainwave reader to arduino by using BlueSMiRF. I am now following a programme someone already did which can be found below. I have faced a problem when I verify the code saying ‘initializer-string for array of chars it too long’. Could anyone possibly help me with the issue please??

The question is probably stupid as I am new to Arduino,

Thanks,

////////////////////////////////////////////////////////////////////////
// Arduino BlueSMiRF initial baudrate changer
//
// This is example code provided by NeuroSky, Inc. and is provided
// license free.
//
// * Connect BlueSMiRF RX and TX to Serial on Arduino board (pins 0 & 1)
// * Connect BlueSMiRF VCC to the pin corresponding to BLUESMIRFON
// *
////////////////////////////////////////////////////////////////////////

/**** CleanProgramBlueSMiRF.pde ****
** Modified by Sean M Montgomery 2010/12
** Programs a BlueSMiRF module with the specified MAC address
** for use with the NeuroSky MindSet.
**
** Modified to do an automatic factory reset to avoid needing
** to run the program twice.
************************************/

/**** SET YOUR MAC ADDRESS HERE ****/

char mac[13] = “/dev/tty.MindWaveMobile-DevA”;

/***********************************/

#define LED 13
#define BLUESMIRFON 2

#define FACTORYRESETBAUD 57600
#define DEFAULTBAUD 115200

char str[3];
char passkey[5] = “0000”;

boolean success = false;

int failOuts[10] = {3,4,5,6,7,8,9,10,11,12};

void setup()
{
//Initialize pins
pinMode(LED, OUTPUT);
pinMode(BLUESMIRFON, OUTPUT);
for (int i=0; i<10; i++) {
pinMode(failOuts*, OUTPUT);*

  • }*

  • // First reset to factory defaults*

  • while (!success) {*

  • RunBlueSmirfSetup(true);*

  • }*

  • success = false;*

  • // Then set up with the correct mac address*

  • RunBlueSmirfSetup(false);*
    }
    *void loop() { *

  • if(success) {*

  • digitalWrite(LED,LOW);*

  • delay(1000);*

  • digitalWrite(LED,HIGH);*

  • delay(1000);*

  • } *
    }
    void RunBlueSmirfSetup(boolean factoryReset) {

  • //Initialize serial ports*

  • if (factoryReset) {*

  • Serial.begin(FACTORYRESETBAUD); *

  • } else {*

  • Serial.begin(DEFAULTBAUD); *

  • } *

  • digitalWrite(BLUESMIRFON, LOW);*

  • delay(2000);*

  • digitalWrite(BLUESMIRFON, HIGH); *

  • delay(2000); //Wait for BlueSMIRF to turn on*

  • Serial.print(’$’); //Send command to put BlueSMIRF into programming mode*

  • Serial.print(’$’);*

  • Serial.print(’$’);*

  • delay(100);*

  • Serial.flush();*

  • //Reset the module*

  • if (factoryReset) {*

  • Serial.print(‘S’);*

  • Serial.print(‘F’);*

  • Serial.print(’,’);*

  • Serial.print(‘1’);*

  • Serial.print(’\r’); *

  • while(Serial.available() < 3);*

  • str[0] = (char)Serial.read();*

  • str[1] = (char)Serial.read();*

  • str[2] = (char)Serial.read(); *

  • if(str[0] == ‘A’ && str[1] == ‘O’ && str[2] == ‘K’) {*

  • success = true;*

  • } else {*

  • success = false;*

  • digitalWrite(failOuts[0],HIGH);*

  • }*

  • delay(100);*

  • Serial.flush();*

  • } else {*

  • //Set the baudrate*

  • Serial.print(‘S’);*

  • Serial.print(‘U’);*

  • Serial.print(’,’);*

  • Serial.print(‘5’);*

  • Serial.print(‘7’);*

  • Serial.print(’\r’); *

  • while(Serial.available() < 3);*

  • str[0] = (char)Serial.read();*

  • str[1] = (char)Serial.read();*

  • str[2] = (char)Serial.read(); *

  • if(str[0] == ‘A’ && str[1] == ‘O’ && str[2] == ‘K’) {*

  • success = true;*

  • } else {*

  • success = false;*

  • digitalWrite(failOuts[1],HIGH);*

  • }*

  • delay(100);*

  • Serial.flush();*

  • //Set the remote MAC address*

  • Serial.print(‘S’);*

  • Serial.print(‘R’);*

  • Serial.print(’,’);*

  • for(int i = 0; i < 12; i++) {*
    _ Serial.print(mac*);_
    _
    }_
    _
    Serial.print(’\r’); *_

* while(Serial.available() < 3);*
* str[0] = (char)Serial.read();*
* str[1] = (char)Serial.read();*
* str[2] = (char)Serial.read(); *
* if(str[0] == ‘A’ && str[1] == ‘O’ && str[2] == ‘K’) {*
* success = true;*
* } else {*
* success = false;*
* digitalWrite(failOuts[2],HIGH);*
* }*
* delay(100);*
* Serial.flush();*

* //Set the passkey*
* Serial.print(‘S’);*
* Serial.print(‘P’);*
* Serial.print(’,’);*
* for(int i = 0; i < 4; i++) {*
_ Serial.print(passkey*);
}
Serial.print(’\r’); *_

* while(Serial.available() < 3);*
* str[0] = (char)Serial.read();*
* str[1] = (char)Serial.read();*
* str[2] = (char)Serial.read(); *
* if(str[0] == ‘A’ && str[1] == ‘O’ && str[2] == ‘K’) {*
* success = true;*
* } else {*
* success = false;*
* digitalWrite(failOuts[3],HIGH);*
* }*
* delay(100);*
* Serial.flush();*

* //Set the BlueSMiRF mode*
* Serial.print(‘S’);*
* Serial.print(‘M’);*
* Serial.print(’,’);*
* Serial.print(‘3’);*
* Serial.print(’\r’);*

* while(Serial.available() < 3);*
* str[0] = (char)Serial.read();*
* str[1] = (char)Serial.read();*
* str[2] = (char)Serial.read(); *
* if(str[0] == ‘A’ && str[1] == ‘O’ && str[2] == ‘K’) {*
* success = true;*
* } else {*
* success = false;*
* digitalWrite(failOuts[4],HIGH);*
* }*
* delay(100);*
* Serial.flush();*

* delay(100);*
* //Exit command mode*
* }*
* Serial.print(’-’);*
* Serial.print(’-’);*
* Serial.print(’-’);*
* Serial.print(’\r’);*
* //delay(100);*
* //Serial.flush();*
* //delay(100);*
* //Serial.end();*
* //digitalWrite(BLUESMIRFON, LOW);*
}
CleanProgramBlueSMiRF CleanProgramBlueSMiRF

this
char mac[13] = “/dev/tty.MindWaveMobile-DevA”;
does not look right.
try
char mac = “/dev/tty.MindWaveMobile-DevA”;

First off,

  1. We prefer that you use the code tags for posting your sketch. Use the '#' button at the top. Read Nick's top two posts in the forum on how to post.
  2. When you get a compilation error (ie. verify) you should post that error message fully. In particular, the line number at the start of the error is very important. In fact, if you should first use that number to figure it out yourself.

Anyway, your issue is here

char mac[13] = "/dev/tty.MindWaveMobile-DevA";

The actual string is too long compared to your buffer declaration. You can simply leave out the number 13 to let the compiler decide your size. Or, if you are going to manipulate that string later, then allocate the maximum size for your needs.

As tttt says, please put code in [ code ] [ /code ] tags to prevent the forum software mangling it.

/**** SET YOUR MAC ADDRESS HERE ****/

char mac[13] = "/dev/tty.MindWaveMobile-DevA";

The string you have supplied does not look like a MAC address to me - it appears to be a UNIX device name. Since the file header refers to itself as 'CleanProgramBlueSMiRF.pde' I'm not sure that this is actually an Arduino sketch, although the code looks Arduino-like. If it's an Arduino sketch I can't understand how it would need to use a UNIX device name.

… Also replace

for(int i = 0; i < 12; i++) {
      Serial.print(mac[i]);
    }

by

Serial.print(mac);