warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

Hi, i have used a scetch for a door lock now the first time i uploaded it there was no problems but i wanted to change to a smaller uno bored, so i uploaded the same scetch as before but im plaged with this same error message-
“C:\Users\User\Downloads\FX2YQ0DI5DS3OY0\FX2YQ0DI5DS3OY0.ino:8:38: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]”
the scetch is a s follows -

#include <Servo.h>

#include <Password.h>

#include <Keypad.h>

Servo myservo; //declares servo
Password password = Password( “7512” ); //password to unlock, can be changed

const byte ROWS = 4; // Four rows
const byte COLS = 4; // columns
// Define the Keymap
char keys[ROWS][COLS] = {
{‘1’,‘2’,‘3’},
{‘4’,‘5’,‘6’},
{‘7’,‘8’,‘9’},
{’*’,‘0’,’#’}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 9, 8, 7, 6 };// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 5, 4, 3 };

// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
Serial.begin(9600);
Serial.write(254);
Serial.write(0x01);
delay(200);
pinMode(11, OUTPUT); //green light
pinMode(12, OUTPUT); //red light
myservo.attach(13); //servo on digital pin 9 //servo
keypad.addEventListener(keypadEvent); //add an event listener for this keypad
}

void loop(){
keypad.getKey();
myservo.write(0);
}
//take care of some special events
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:

Serial.print(“Enter:”);
Serial.println(eKey);
delay(10);

Serial.write(254);

switch (eKey){
case ‘*’: checkPassword(); delay(1); break;

case ‘#’: password.reset(); delay(1); break;

default: password.append(eKey); delay(1);
}
}
}
void checkPassword(){

if (password.evaluate()){ //if password is right open

Serial.println(“Accepted”);
Serial.write(254);delay(10);
//Add code to run if it works
myservo.write(150); //deg

digitalWrite(11, HIGH);//turn on
delay(5000); //wait 5 seconds
digitalWrite(11, LOW);// turn off

}else{
Serial.println(“Denied”); //if passwords wrong keep locked
Serial.write(254);delay(10);
//add code to run if it did not work
myservo.write(0);
digitalWrite(12, HIGH); //turn on
delay(500); //wait 5 seconds
digitalWrite(12, LOW);//turn off

}
}

I just cant understand why it its throwing that error message up, also if ignored then it will not work properly, thank you for any help anyone can give me thanks. Riche

Whoever wrote that library doesn't know to use the "const" keyword. I doubt your problem has anything to do with that warning, though.

I3ORG:
I just cant understand why it its throwing that error message up, also if ignored then it will not work properly, thank you for any help anyone can give me thanks. Riche

I suspect the Password constructor takes a "char *" and not a "const char *". The warning is to tell you that the Password constructor is reserving the right to WRITE INTO YOUR STRING CONSTANT. The library should be fixed.
The warning should not cause a problem if the Password constructor doesn't ACTUALLY write into your string constant (and it probably doesn't). If the code doesn't work the problem is probably elsewhere.

lluft1:
Hello guys, I am pretty new with arduino and I downloaded a code tried to change the password and then I tried to run it but it showed an error:

C:\Users\Luigi Luft\AppData\Local\Temp\Rar$DIa0.283\keypad_password_servo\keypad_password_servo.ino:9:40: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

Password password = Password( “148795” );//password to unlock box, can be changed

^




The code I downloaded:




#include <Password.h> //http://playground.arduino.cc/uploads/Code/Password.zip use password library
#include <Keypad.h> //http://www.arduino.cc/playground/uploads/Code/Keypad.zip  //tells to use keypad library
#include <Servo.h> //tells to use servo library

Servo myservo; //declares servo
Password password = Password( “148795” );//password to unlock box, can be changed

const byte ROWS = 4; // Four rows
const byte COLS = 4; // columns
// Define the Keymap
char keys[ROWS][COLS] = {
{‘1’,‘2’,‘3’,‘A’},
{‘4’,‘5’,‘6’,‘B’},
{‘7’,‘8’,‘9’,‘C’},
{’*’,‘0’,’#’,‘D’}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 5, 4, 3, 2 };// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 8, 7, 6, 9 };

// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
 Serial.begin(9600);
 Serial.write(254);
 Serial.write(0x01);
 delay(200);
 pinMode(11, OUTPUT);  //green light
 pinMode(12, OUTPUT);  //red light
 myservo.attach(13); //servo on digital pin 9 //servo
 keypad.addEventListener(keypadEvent); //add an event listener for this keypad
 }

void loop(){
 keypad.getKey();
 myservo.write(0);
 }
 //take care of some special events
 void keypadEvent(KeypadEvent eKey){
 switch (keypad.getState()){
 case PRESSED:
 
 Serial.print("Enter: ");
 Serial.println(eKey);
 delay(10);
 
 Serial.write(254);
 
 switch (eKey){
   case ‘A’: checkPassword(); delay(1); break;
   
   case ‘B’: password.reset(); delay(1); break;
   
    default: password.append(eKey); delay(1);
}
}
}
void checkPassword(){
 
if (password.evaluate()){  //if password is right open box
   
   Serial.println(“Accepted”);
   Serial.write(254);delay(10);
   //Add code to run if it works
   myservo.write(5); //160deg
   
       digitalWrite(11, HIGH);//turn on
   delay(500); //wait 5 seconds
   digitalWrite(11, LOW);// turn off
   
   
}else{
   Serial.println(“Denied”); //if passwords wrong keep box locked
   Serial.write(254);delay(10);
   //add code to run if it did not work
   myservo.write(0);
   digitalWrite(12, HIGH); //turn on
   delay(500); //wait 5 seconds
   digitalWrite(12, LOW);//turn off
   
}
}




can someone help me to figure this out?

Did you ever get theis warning nailed? I have the same problem with the same code, it worked once then when i went to put the code back on again i to have that same error message on all three pcs and on both arduinos after the code working the once, and yet no one in this forum makes sense on this issue.

I already explained this. Read what I wrote:

pert:
You need to understand the difference between warnings and errors. This is a warning, not an error. It's always a good idea to fix all the warnings you possibly can, which you can do in this case like this:

char myPassword[] = "148795";

Password password = Password(myPassword);//password to unlock box, can be changed



or by casting:


Password password = Password((char *)"148795");//password to unlock box, can be changed

http://forum.arduino.cc/index.php?reportsent;topic=492662.msg3361550#msg3361550

God dam keyboard warriors!

No real help given just loads of mods that need to wind our necks in, I mean really did it take that many of you to tell me a 43 man that I had double posted and some even accusing me of posting six months ago, like I pmd some of you just so as its clear about this real bad event that I caused was a pure mistake, yes I posted the otherday BUT lost the post as I had forgot to put the notification on and it was NOT showing up under anything I had started so I had to do it again but this time putting the notifications on, now also all the help that has been posted on this topic has NOT solved the issue, so please help if not I don't have time for jumped up grumpy wannabes im hear to learn my arduino not to be bullied on some forum!

pert:
I already explained this. Read what I wrote:

That didnt work and like you said to the other guy, its a warning not an error so why would it solve the problem if i alter the code?

johnwasser:
I suspect the Password constructor takes a "char *" and not a "const char *". The warning is to tell you that the Password constructor is reserving the right to WRITE INTO YOUR STRING CONSTANT. The library should be fixed.
The warning should not cause a problem if the Password constructor doesn't ACTUALLY write into your string constant (and it probably doesn't). If the code doesn't work the problem is probably elsewhere.

Thanks for the replays, i have tried installing the software again rebuilding the liabry but still the same problem the od thing is that it did work on two boards but once i have put another scetch on it would never let me put the above code back on again with out that warning, across three pcs to.

Wow the amount of abuse you get after loseing ur post.

http://forum.arduino.cc/index.php?topic=492662.new#new

Because @I3ORG cannot follow one simple instruction (do not cross-post) they will be spending some time away from the forum.

When you return @I3ORG, if you deliberately waste my time again I will permanently ban you.

Threads split and merged.