Code writing

I really need help writing a code as I'm new to this
Is there any good soul out there that will help me with skills
In getting code made please what it is I am trying to do is have a keypad
LCD screen a beeper and a relay I want a code so that when I put in the pin correct code on the keypad it starts to count down and beep and when it gets to (0) the realy is powered on for about 30 seconds
I would willing to pay $10 with PayPal if some one would like to make the code for me

My usual rate is easily over 10 times that an hour! Besides, it sounds like homework - right?

no it's not home work it's for a model rocket luncher I want to make as it only home work to you
why ask for so much money for something you can do so easily your help would be great but I don't think you are willing to help me thanks replaying I guess

Hi,

It does sound like homework, not to be insulting, but you have just asked for someone to solve your problem, without effort from you. Still could be worse like asking someone to help you arm a bomb :slight_smile:

I am new here also and find it hard to ask the correct questions, seems that always someone takes it the wrong way, myself included when it comes to the answers!

All the best

About the Only free thing is advice... and it's up to you to learn enough to know good from bad.. So Far the advice has been IMO perfect.

I really need help writing a code as I'm new to this

If you don't start now then you will always be new to it. You are not asking for help to write code, you are asking for someone to write it for you. Have you tried to write it and, if so, what problems did you have ?

its definitely not home work i didn't even know you could do classes in arduino all do i could do with a few i have tried to make the code my self ill put put it up. i have made the examples and read loads text for many hours i just seen to end up confusing my self more the code i have will count down for me but i want to add the keypad matrix so i can have it start to countdown when a correct code is entered i have added the keypad layout but i dont what to do with the pins cos the LCD takes most of them up so i just put (0)'s in for now i was also thinking i could make the row pins on the keypad high as in connected to +5v and the columns pins on to the arduino so when pressed them would take the input and some how move the code on to the next part but have no idea how to do this having some one do the code for would be great and i did offer $10 for it but in the first part of my original post i asked for someone to help me make the code with i prefer that so i mite one day be able to write my own code form starch any way here is my code if you can call it that i just want a pass code please

#include <LiquidCrystal.h>
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
	{'1','2','3'},
	{'4','5','6'},
	{'7','8','9'},
	{'*','0','#'}
	};
byte rowPins[ROWS] = {, 0, 0, 0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {0, 0, 0}; //connect to the column pinouts of the keypad
	
 // initialize the library with the numbers of the interface pins
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
 int runTimer = 1; // true condition for timer
 int serialData = 0; // false condition for serial communication
 int relayPin = 8;
 int data = 0; // default condition
 
 void setup() {
   pinMode(relayPin, OUTPUT);
 
   // set up the LCD's number of rows and columns: 
   lcd.begin(16, 2);
 }

 void loop() {
   
   // To execute timer only once
   if(runTimer == 1){ 

   // Print a message to the LCD.
   lcd.clear();
   lcd.print("CountDown: ");
   //Start timer
   timer(); 
   }
   runTimer = 0;
   lcd.noDisplay();
   delay(250);
   // relaay
   for(int duration = 0; duration < 100; duration ++){
     digitalWrite(relayPin, HIGH);
     delayMicroseconds(8000);
     digitalWrite(relayPin, LOW);
     delayMicroseconds(2000);
   } 
   lcd.display();
   delay(250);
   
   while (1);
 }
 
 void timer(){
   
   // For loop to run the COUNT-DOWN in Seconds
     for(int timer = 10; timer > 0; --timer){
     // Set the Curosr to the space after the display "TIMER: "
     if(timer >= 10)
       lcd.setCursor(6,0);  
     else{
       lcd.setCursor(6,0);
       lcd.print("0");
       lcd.setCursor(7,0);
     }
     // Display the COUNT-DOWN Seconds
     lcd.print(timer);
     lcd.print("s");
     delay(1000);
     }
     
     // Bring the Cursor to the initial position 
     lcd.setCursor(0,0);
     lcd.clear();
     lcd.print("   !Take Off!");

}

OK - you have made a start. What does the program do when you run it ?
Actually you can't run it because it won't compile because you need 4 pin values in the ROWS dimension of the keys array.

What Arduino are you using ? For now I am going to assume that you have a Uno. You will have plenty of pins to which you can attach the keypad. Remember you can use the analogue pins (A0 to A5) as digital inputs if you need to.

As you are not experienced in coding I would suggest that you write separate programs to test the different aspects of your final program and get each working before you combine the ideas. For instance, learn to use the keypad by reading key presses and displaying them then check the input against a codes password in the program.

Thanks for the reply I will do as you suggested would you know of a tutorial about key reading the keys

I for got to say if I take out the keypad part out the sketch runs counts down from 10 and powers the relay for about 10-20 seconds and stops I want to add the password "pin" to this to start this up

The keypad.zip file from Arduino Playground - HomePage has example code for reading the keypad.

Thanks I'll try this out when I get some free time I hope I get the hang of it

so i tryed out the link you gave me but little joy i was using the event keypad examples got that working
but i need to use the ' char waitForKey() ' function but have no clue how to add this /use this any help would be great

i have made the pass code  sketch and the count down sketch but how do i add them together this one is the pass code sketch
ill put the count down sketch up next



LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

Password password = Password( "1212" );

const byte ROWS = 4; // Four rows
const byte COLS = 3; //  columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};

byte rowPins[ROWS] = { A0,A1,A2,6 };// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte colPins[COLS] = { A3,A4,A5};// Connect keypad COL0, COL1 and COL2 to these Arduino pins.


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

void setup(){
 pinMode(speakerPin, OUTPUT);
 
  lcd.begin(16, 2);
  lcd.print(" **Enter Code**");
  Serial.begin(9600);
  keypad.addEventListener(keypadEvent); //add an event listener for this keypad
}

void loop(){
  keypad.getKey();
  if(runTimer==1);
  
}

//take care of some special events
void keypadEvent(KeypadEvent eKey){
  switch (keypad.getState()){
    case PRESSED:
	Serial.print("Pressed: ");
	Serial.println(eKey);
	switch (eKey){
	  case '*': checkPassword(); break;
	  case '#': password.reset(); break;
	  default: password.append(eKey);

     }
  }
}

void checkPassword(){
    
  if (password.evaluate()){
    Serial.println("Success");
    lcd.clear();
    lcd.print("     Success ");



    lcd.setCursor(6,1);
    
    
    
    
    //Add code to run if it works
  }else{
    Serial.println("Wrong");
    //add code to run if it did not work
  }
}
#include <LiquidCrystal.h>
 // initialize the library with the numbers of the interface pins
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
 int runTimer = 1; // true condition for timer
 int serialData = 0; // false condition for serial communication
 int speakerPin = 8;
 int data = 0; // default condition
 
 void setup() {
   pinMode(speakerPin, OUTPUT);
 
   // set up the LCD's number of rows and columns: 
   lcd.begin(16, 2);
 }

 void loop() {
   
   // To execute timer only once
   if(runTimer == 1){ 

   // Print a message to the LCD.
   lcd.clear();
   lcd.print("Timer: ");
   //Start timer
   timer(); 
   }
   runTimer = 0;
   lcd.noDisplay();
   delay(250);
   // Sound Buzzer
   for(int duration = 0; duration < 100; duration ++){
     digitalWrite(speakerPin, HIGH);
     delayMicroseconds(8000);
     digitalWrite(speakerPin, LOW);
     delayMicroseconds(2000);
   } 
   lcd.display();
   delay(250);
   
   while (1);
 }
 
 void timer(){
   
   // For loop to run the COUNT-DOWN in Seconds
     for(int timer = 10; timer > 0; --timer){
     // Set the Curosr to the space after the display "TIMER: "
     if(timer >= 10)
       lcd.setCursor(6,0);  
     else{
       lcd.setCursor(6,0);
       lcd.print("0");
       lcd.setCursor(7,0);
     }
     // Display the COUNT-DOWN Seconds
     lcd.print(timer);
     lcd.print("s");
     delay(1000);
     }
     
     // Bring the Cursor to the initial position 
     lcd.setCursor(0,0);
     lcd.clear();
     lcd.print("   !Take Off!");
 }

so i got the code working for what i want to do but i now i want it to return to starts after it run any ideas on how i could do this

#include <Password.h> 
#include <Keypad.h> 
#include <LiquidCrystal.h>
#define READY 1

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int runTimer=1;
int serialData =0;
int speakerPin=8;
int data=0;
Password password = Password( "1111" );

const byte ROWS = 4; // Four rows
const byte COLS = 3; //  columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {
    '1','2','3'      }
  ,
  {
    '4','5','6'      }
  ,
  {
    '7','8','9'      }
  ,
  {
    '*','0','#'      }
};

byte rowPins[ROWS] = { 
  A0,A1,A2,6 };// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte colPins[COLS] = { 
  A3,A4,A5};// Connect keypad COL0, COL1 and COL2 to these Arduino pins.


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

void setup(){
  pinMode(speakerPin, OUTPUT);

  lcd.begin(16, 2);
  lcd.print(" **Enter Lunch**");
  lcd.setCursor(0,1);
  lcd.print("   <<<Code>>>");
  Serial.begin(9600);
  keypad.addEventListener(keypadEvent); //add an event listener for this keypad
}

void loop(){
  keypad.getKey();


}

//take care of some special events
void keypadEvent(KeypadEvent eKey){
  switch (keypad.getState()){
  case PRESSED:
    Serial.print("Pressed: ");
    Serial.println(eKey);
    switch (eKey){
    case '*': 
      checkPassword(); 
      break;
    case '#': 
      password.reset(); 
      break;
    default: 
      password.append(eKey);

    }
  }
}

void checkPassword(){

  if (password.evaluate()){
    Serial.println("Success");
    lcd.clear();
    lcd.print("   Success :) ");
    lcd.setCursor(4,1);
    lcd.print("Entered");
    delay(5000);
    

    pinMode(speakerPin, OUTPUT);

    // set up the LCD's number of rows and columns: 
    lcd.begin(16, 2);
  }



    // To execute timer only once
    if(runTimer == 1){ 

      // Print a message to the LCD.
      lcd.clear();
      lcd.print("Timer: ");
      //Start timer
      timer(); 
    }
    runTimer = 0;
    lcd.noDisplay();
    delay(250);
    // Sound Buzzer
    for(int duration = 0; duration < 100; duration ++){
      digitalWrite(speakerPin, HIGH);
      delayMicroseconds(8000);
      digitalWrite(speakerPin, LOW);
      delayMicroseconds(2000);
    } 
    lcd.display();
    delay(250);

    while (1);
  }

  void timer(){

    // For loop to run the COUNT-DOWN in Seconds
    for(int timer = 10; timer > 0; --timer){
      // Set the Curosr to the space after the display "TIMER: "
      if(timer >= 10)
        lcd.setCursor(6,0);  
      else{
        lcd.setCursor(6,0);
        lcd.print("0");
        lcd.setCursor(7,0);
      }
      // Display the COUNT-DOWN Seconds
      lcd.print(timer);
      lcd.print("s");
      delay(1000);
    }

    // Bring the Cursor to the initial position 
    lcd.setCursor(0,0);
    lcd.clear();
    lcd.print("   !Take Off!");
   }

but i now i want it to return to starts after it run any ideas on how i could do this

First, I'd suggest that you start using capital letters and punctuation. This run on sentence is gibberish.

Then, you need to stop using "it" so much. It is a pronoun, and in most of your uses, we are left to guess what "it" refers to. Make it easy. Quit using "it".

Third, you need to define what "starts" is. How to return to "starts" depends on what starts is.

The call to getKey() in loop is discarding the value that it got, if any, so the call is useless. You might as well remove it.

All of your code is in the keypadEvent() which is triggered when a key is pressed. To "return to starts", you simply need to allow keypadEvent() to reach the end.

What it is i want to be able to do is have my code return to the start once it has run any help with this please

Unbelievable! - Scotty

It seems to me like you were getting a ton of help in this thread:

http://arduino.cc/forum/index.php/topic,157097.0.html

This thread may help a ton How to use this forum

Might want to try and use proper punctuation. As in the other thread you started, what is "it?"

But, I can help with one thing

return to the start once it has run

You put it in loop()