Using multiple passwords

I working on a project that would launch rockets. The first version that I have works great and all, but I would like to add more user/password that would say and or display there name when they enter their own passwords. I have some knowledge to using one password, not using two or more. I have read everything that I could find on the internet but it not given me a good enough example to play with to be able to add it to the project. I learn the best by trail and error, just a whole lot of errors at the moment. Any help with this I would be grateful for, along with my nephews. File attach is part of the first version of the code used, this one only has the code need to use LCD display and keypad.

Multi_password.ino (11.4 KB)

That is confusing. DO you have one password working, but not more than 1? What is it exactly you want to do with passwords? You do not seem to have a good plan in mind.

Paul

So,

 if (key == '1')
  {
    mypassword = mypassword + 1;
    digitalWrite(buzz,HIGH);
    delay(50);
    digitalWrite(buzz,LOW);
  }
  if (key == '2')
  {
    mypassword = mypassword + 2;
    digitalWrite(buzz,HIGH);
    delay(50);
    digitalWrite(buzz,LOW);
  }
  if (key == '3')
  {
    mypassword = mypassword + 3;
    digitalWrite(buzz,HIGH);
    delay(50);
    digitalWrite(buzz,LOW);
  }
  if (key == '4')
  {
    mypassword = mypassword + 4;
    digitalWrite(buzz,HIGH);
    delay(50);
    digitalWrite(buzz,LOW);
  }
  if (key == '5')
  {
    mypassword = mypassword + 5;
    digitalWrite(buzz,HIGH);
    delay(50);
    digitalWrite(buzz,LOW);
  }
  if (key == '6')
  {
    mypassword = mypassword + 6;
    digitalWrite(buzz,HIGH);
    delay(50);
    digitalWrite(buzz,LOW);
  }
  if (key == '7')
  {
    mypassword = mypassword + 7;
    digitalWrite(buzz,HIGH);
    delay(50);
    digitalWrite(buzz,LOW);
  }
  if (key == '8')
  {
    mypassword = mypassword + 8;
    digitalWrite(buzz,HIGH);
    delay(50);
    digitalWrite(buzz,LOW);
  }
  if (key == '9')
  {
    mypassword = mypassword + 9;
    digitalWrite(buzz,HIGH);
    delay(50);
    digitalWrite(buzz,LOW);
  }
  if (key == '0')
  {
    mypassword = mypassword + 0;
    digitalWrite(buzz,HIGH);
    delay(50);
    digitalWrite(buzz,LOW);
  }

can be replaced with

 if ( isdigit(key) )
  {
    mypassword = mypassword + key - '0';
    digitalWrite(buzz,HIGH);
    delay(50);
    digitalWrite(buzz,LOW);
  }

the project was something that my nephews wanted. One code does work. They would like it when they enter the password that it would display their names. I can write the code for that, just couldn't figure out out how to use multi codes. Seen video of it being done just can't reach the site for some reason for the code and waiting on reply from the user of the video for some time now. As for the plan I do, I don't code for a living and just play around with it. I know my is code somewhat a mass, and there are better ways. This was something I put together when I first found out about Arduinos and I trying to learn more about it and the language used.

1234 - display Nephew A name, then launch
5678 - display Nephew B name, then launch

May I suggest - I didn't come out and say it but maybe I should be more explicit. Doing a huge upgrade modification on a piece of code that is badly written, is going to be a much more painful experience than fixing it, and then upgrading it.

The pedestrian approach that I eliminated in reply #2 will hamper every step you take in modifying it for multiple users.

One possibility: Make a structure consisting of password and name. Then create an array of these structures. When password entered search the password member of the structures to find a match. If found, print the name member.

Regarding the massive repetition for the "----04----" stuff, it's time to learn about functions and millis() timing.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.