Question answer lock

hello, im new in arduino so hoping for your help since i have no experience what so ever with arduino besides 3d printing.

i´m searching for a programmingcode that enables an arduino to move a servo when the right code was enterd after a questioncode from the program has been generated.

sorry for my bad explenation and gramar.

here the function:
when a button has been pressed the display shows a, lets say 6digit code, so i have to look at a list and finde the code. there in the list is a second code that is the answer, so with a pad i enter the second code and the servo is moving.

oh the arduino doesnt need to generate the code, just copied into the code, i think this is simler than generating it by itself?

i hope that someone could provide me with something like it. please dont feel offendet by this request. i belive that you have more programing experience and knowledge in your first days than i will ever get in my life. i´m not searching the easy way, this is more desperation speaking.

thanx

Why not have a go at coding it yourself? It sounds like an ideal first project and would be the best way to learn.
Break the project into small pieces and study how each bit works, start with these tutorials:

yes i tried several tutorials and learningbooks, sad thing is that i propably dont have the capabilities to understand programing. guess i´m not made for the higher understanding of it. i tried it for about 2 months but still i did more damage to 2 boards than good. hardware andmechanical stuff is my world.
i do appreciate your help and will give it a try, but i do not see any chance to start building it from scratch, i know a simple 4 pin padlock programming code that does most of what i want but trying to adapt it or learn from it is not working for me at all.
thanx
br

There's still a few options left...

  • Night classes for an introduction programming (expect to find similar people).
  • Have another go at modifying the code you have and post another question (expect to be berated for not using code tags).
  • The Gigs and Collaborations section of the forum (expect no mercy).

Best of luck!

Nubi:
i know a simple 4 pin padlock programming code that does most of what i want but trying to adapt it or learn from it is not working for me at all.

Well, you can complain that you don't get it, in which case we can't help. Or you can post the code and ask questions and we can help you learn. Or you can post your attempts and what happened and we can help you understand why.

happy to post the code to get the help:

thats the code i found so far but now i need to put in a list from where the code is shown first so i type the answer in.
so i need to place a list from where the code is read out so i can switch the Password for a varriable that is read out from the same line where i have the question in. how should such a list look like? or will it have to be a seperate library? is it a library?

i would need a random readout like this:

randomSeed(analogRead(0));
}

void loop() {
// print a random number from 0 to 500
randNumber = random(501);
Serial.println(randNumber);

delay(50);
}

then the outcome determens what code should be used for question this is used by Serial.print but i do not understand how to use a variable instead of a text.

This is the actual pin lock i´m planing to use further on.

#include <Password.h>
#include <LiquidCrystal.h>
#include <Keypad.h>
LiquidCrystal lcd(2,3,4,9,10,11,12);
Password password = Password( "4321" );
const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three 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] = {25, 24, 23, 22}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {28, 27, 26}; //connect to the column pinouts of the keypad
const int buttonPin = 7;
int buttonState = 0;

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

#define ledPin 13

void setup(){
pinMode(buttonPin, INPUT);
lcd.begin(16, 2);
digitalWrite(ledPin, LOW); // sets the LED on
Serial.begin(9600);
keypad.addEventListener(keypadEvent); //add an event listener for this keypad
keypad.setDebounceTime(250);
}

void loop(){
keypad.getKey();
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
lcd.clear();
}
}

//take care of some special events
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
lcd.print(eKey);
switch (eKey){
case ' ': guessPassword(); break;
default:
password.append(eKey);
}
}}

void guessPassword(){
if (password.evaluate()){
digitalWrite(ledPin,HIGH); //activates garaged door relay
delay(500);
digitalWrite(ledPin,LOW); //turns off door relay after .5 sec
lcd.print("VALID PASSWORD "); //
password.reset(); //resets password after correct entry
delay(600);
lcd.print("Welcome");
delay(2000);
lcd.clear();
}

else{
digitalWrite(ledPin,LOW);
lcd.print("INVALID PASSWORD ");
password.reset(); //resets password after INCORRECT entry
delay(600);
lcd.clear();
}
}

So your random number will pick one out of the list of questions. Here's a big hint, such a list is called an array and picking one out using a number is one of the easiest of operations. With 500 such questions, you're going to have to keep the text in flash memory. That's a bit more code. Start out with 5 questions and get it working and then we'll help you bump it up without running into memory issues.

Have a google at "C++ array) and see what you can learn. Defining your array might look like this:

char* questionTexts[5] = {"What is your name?" , "What is your quest?" , "What is your favorite color?" , "What is the capital of Assyria?" , "What is the air speed velocity of an unladen swallow?"}

And then you could get one or another out with something like:

Serial.println(questionTexts[someVariable]);

Where someVariable is a variable that has a number 0, 1, 2, 3, or 4 to choose which question from the list.