arduino bomb prop code probleem, help aub !!

algemene C code
Berichten: 6
Geregistreerd: 04 Okt 2013, 15:22

arduino bomb prop code probleem, help aub !!

Berichtdoor silentwolf » 04 Okt 2013, 15:30

Ik kom hier mijn probleem melden met de hoop dat iemand mij zou kunnen helpen want ik geraak niet verder, wat ik ook doe...

Het probleem komt erop neer dat er eigenlijk geen registratie gebeurt van mijn keypad. Normaal zou ik een code moeten ingeven (admin, arm, disarm) maar deze verschijnt niet op het lcd scherm. Het enige wat hij voorlopig wel accepteert is het # symbool. Dit wordt gebruikt voor het menu in te gaan.

Ik gebruik een arduino duemilanove, een 20x4 LCD en een 3x4 matrix keypad.

Ik heb de code al aangepast want was oorspronkelijk bedoeld voor een serial LCD maar dat heb ik niet.

hier mijn code.

Code: Alles selecteren

 /******************************************************************************************
* Airsoft Bomb Prop by Joshua Burgess
* Edited by silentwolf
* v5.0.3 Last updated: 04/10/2013
 
*******************************************************************************************/
 
 
 #include <Keypad.h>
 #include <EEPROM.h>
#include "EEPROMAnything.h"
#include <LiquidCrystal.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};

byte rowPins[ROWS] = {19, 18, 17, 16}; //connect to the row pinouts of the keypad

byte colPins[COLS] = {15, 14, 7}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); 
 
//Define all the bomb states 
#define READY 0
#define ARMED 1
#define DISARMED 2
#define DETONATED 3

int second=30, minute=10, hour=0; // declare time variables
int bombState=0; //0 = Ready, 1 = Armed, 2 = Disarmed, 3 = detonated
int configMenuFlag = 0; //prevents configMenu from launching after a key is pressed
int speakerPin = 9;//pin that the piezo buzzer is connected to.

//variables for buzzer chirp function
static unsigned long currentMillis = 0;
long previousTime = 0;//holds previous time in ms
long previousDelay = 0;//holds previous time in ms since buzzer was active

int stop = 0;//function kill flag
long code = 0;//keeps a running tally of the digits entered into the keypad
int count = 0;//number of correct digits

char ArmCode[] = "1234";//code to arm the bomb
char disarmCode[] = "1234";//code to disarm the bomb
char adminCode[] = "1234";//code to change timer

//configuration
//structure for storing the arm code, disarm code, admin code, and time in the eeprom memory
struct config_t
{
    long arm;
    long disarm;
    long admin;
    int c_hour;
    int c_minute;
    int c_second;
} configuration;

void setup()
{
lcd.begin(20, 4);
lcd.cursor();
lcd.setCursor(0, 0);
  pinMode(speakerPin, OUTPUT);//sets the output pin for the piezo buzzer
 
  readConfig();//read in the arm, disarm, admin codes and timer
  //saveConfig();
  //display the default timer when prop boots up
  lcd.clear();
  delay(1000);
    selectLineTwo();
    lcd.print(hour, DEC); // the hour, sent to the screen in decimal format
    lcd.print(":"); // a colon between the hour and the minute
    lcd.print(minute, DEC); // the minute, sent to the screen in decimal format
    lcd.print(":"); // a colon between the minute and the second
    lcd.print(second, DEC); // the second, sent to the screen in decimal format
    delay(1000);
    lcd.clear();
}

void loop(){
   
  switch (bombState) {
 
/***********************************************************
*Ready state prepares bomb, waits for arm code to be input *
*                                                          *
************************************************************/
  case READY:
    while (count < (sizeof(ArmCode) - 1)) {//loop until the full and correct arm code is entered
     
      selectLineTwo();
      lcd.print("Enter ArmCode");
     
    selectLineOne();
    lcd.print("Code"); //prompt for arm code
   lcd.print(":");
 
       
    char key;
   
      do{
        key = keypad.getKey();
        }
     while(key == NO_KEY);
   
   code = (code * 10) + (key - 48); //stores the current correct digits for display later
   
   if(key == '#' && configMenuFlag == 0) {//check if user wants to enter menu
               //key = '\0';
               configMenu();// enter menu
              count = 0;
              code = 0;
              lcd.clear();
             
   }
   
   
   else if(key == ArmCode[count]) {//if the key matches the code
             // key = '\0';
              count++;
              configMenuFlag = 1;//once the code is started, the menu cannot be entered   
        }
   
   else { //if the key does not match the code, reset
              count = 0;
              code = 0;
              configMenuFlag = 1;//once the code is started, the menu cannot be entered
              lcd.clear();
          }
   
 selectLineOne();
    lcd.print("Code"); //prompt for arm code
   lcd.print(": ");
    lcd.print(code);//display correct digits that have been entered
   
  }//end while
 
  lcd.clear();
  bombState = ARMED;//when the correct code has been entered, move to armed state
  count = 0;
  code = 0;
 
  break;


/***********************************************************
*Armed *
*                                                          *
************************************************************/
  case ARMED:
   
    selectLineOne();
    lcd.print("Code"); //prompt for disarm code
   lcd.print(": ");
 
       
    char key;
      do{
        key = keypad.getKey();
        countdown();//displays countdown while simultaneously checking for disarm code
     
      if (second == 0 && minute == 0 && hour == 0) {
      code = 0;
      lcd.clear();
      bombState = DETONATED; //clear LCD and set bomb state to "detonated" when timer runs out 
    break; 
  } 
        //if the correct code is entered, move to disarmed state
    else if(count == (sizeof(disarmCode) - 1)){
      code = 0; 
      lcd.clear();
        bombState = DISARMED;
    }
     
    }//end do
     while(key == '\0' && bombState == ARMED);
   
   code = (code * 10) + (key - 48); //store correct digits for display later
   
   //if the key entered matches the disarm code, increase count.
   if(key == disarmCode[count]) {
              count++;
            }
           
 
   
   else {
              count = 0;
              code = 0;
              lcd.clear();
          }
   
 selectLineOne();
    lcd.print("Code"); //prompt for arm code
   lcd.print(": ");
    lcd.print(code);//display the current correct digits
     
break;

/*******************************************************
*Detonated. activate buzzer for 8 beeps, then 1 long.
*Print bomb detonated message to LCD.
********************************************************/
  case DETONATED:
  lcd.clear();

 digitalWrite(speakerPin, HIGH);//turn on buzzer
 delay(5000);//wait 5 seconds
 digitalWrite(speakerPin, LOW);//turn off buzzer
 
  selectLineOne();
  lcd.print(">Bomb Detonated<"); //loop message informing user of bomb detonation.
 
 
  do{
     stop = 1;
  }
  while(stop == 1);//endless loop stops program
 
/**************************************************************
*DISARMED. Counter stopped, displays "bomb disarmed"
*
**************************************************************/
  case DISARMED:
 
  selectLineOne();
    lcd.print("Bomb Disarmed"); //bomb has been disarmed, inform user.
 
  do{
    int stop = 1;
  }
  while(stop == 1);//endless loop stops program
 
 
  }//end case statements   
}

/***********************************************************
* Main countdown timer                                     *
*                 countdown()                              *
************************************************************/
void countdown(){
 
  static unsigned long lastTick = 0; // set up a local variable to hold the last time we decremented one second

// (static variables are initialized once and keep their values between function calls)

// decrement one second every 1000 milliseconds
  if (second > 0) {
      if (millis() - lastTick >= 1000) {
          lastTick = millis();
          second--;
      }
  }

 // decrement one minute every 60 seconds
  if (minute > 0) {
      if (second <= 0) {
          minute--;
          second = 60; // reset seconds to 60
         
      }
  }

// decrement one hour every 60 minutes
  if (hour > 0) {
      if (minute <= 0) {
          hour--;
          minute = 60; // reset minutes to 60
      }//closes if
  }//closes if
 
 beepSecondaryBuzzer();
 
  //the code below beeps the siren once every minute.
  /*
  currentMillis = millis();
  if (currentMillis - previousTime > interval)
  {
    previousTime = currentMillis;
    previousDelay = currentMillis;
   
   digitalWrite(speakerPin, HIGH);//turn on buzzer
  }
 
  if (currentMillis - previousDelay > 100) {//100ms chirp duration
    digitalWrite(speakerPin, LOW);//turn off buzzer
  }
  */
 
  selectLineTwo();

  lcd.print("ARMED: ");
  lcd.print(hour, DEC); // the hour, sent to the screen in decimal format
  lcd.print(":"); // a colon between the hour and the minute
  lcd.print(minute, DEC); // the minute, sent to the screen in decimal format
  lcd.print(":"); // a colon between the minute and the second
  lcd.print(second, DEC); // the second, sent to the screen in decimal format
  lcd.print(" ");
} //close countdown();


/*********************************************************************
*       Serial LCD functions for Newhaven serial LCD                 *
*   selectLineOne(); | selectLineTwo();  | clearLCD();               *
*   setDefaultContrast(); | dispOn() | boxCursorOn() | serCommand(); *
**********************************************************************/
void selectLineOne(){  //puts the cursor at line 0 char 0.
   lcd.cursor ();  //command flag
   lcd.setCursor (0, 1);  //position command
    //cursor positon 0 = start of first line
}
void selectLineTwo(){  //puts the cursor at line 0 char 0.
   lcd.cursor();   //command flag
   lcd.setCursor(0, 0);    //position command
   // cursor postion 40 = start of second line
}



/***********************************************************
* admin code, arm code, disarm code, and timer editing     *
* function.                                                *
*                 configMenu();                            *
************************************************************/
void configMenu(){
int exitMenu = 0;
int back = 0; //prevent user from exiting without typing in full code
char menuPage; //prompt for Menu page

lcd.clear();
selectLineOne();
lcd.print("Menu");//inform the user that they are entered the menu
delay(500);
lcd.clear();

 
  code = 0;
  count = 0;
  while (count < (sizeof(adminCode) - 1)) {
    selectLineTwo();
   lcd.print("Enter AdminCode"); 
   
    selectLineOne();
    lcd.print("Code"); //prompt for admin code
   lcd.print(": ");
 
       
    char adminKey;
      do{
        adminKey = keypad.getKey(); //loop and wait for keypress
        }
     while(adminKey == '\0');
   
   code = (code * 10) + (adminKey - 48);//store correct digits for later use
   if(adminKey == '#') {
              return;//return to the arm code state
              count = 0;
              code = 0;
              lcd.clear();
   }
   
   //if the correct key is pressed
   else if(adminKey == adminCode[count]) {
              count++;
            }
   
   else {
              count = 0;
              code = 0;
              lcd.clear();//if the key is incorrect, reset
          }
   
 selectLineOne();
    lcd.print("Code"); //prompt for admin code
   lcd.print(": ");
    lcd.print(code);//display correct digits
   
  }//end while
 
  lcd.clear();
 do { //display menu
 selectLineOne();
 lcd.print("1.Admin 2.Time");
 selectLineTwo();
 lcd.print("3.Arm 4.Disarm");
 
      do{
        menuPage = keypad.getKey(); 
        } //keep reading if anything but 1 - 4 is entered
     while(menuPage == '\0' || menuPage == '*' || menuPage ==  '0' || menuPage > 52);
 
 
 switch(menuPage) {
   
  case '1': // Edit admin code
 
  lcd.clear();
  selectLineTwo();
  lcd.print("# To Exit");
  delay(2000);
  lcd.clear();
 
   selectLineTwo();
   lcd.print("AdminCode");

   selectLineOne();
   lcd.print("Code"); //prompt for admin code
   lcd.print(": ");
   
     count = 0;
     code = 0;//
    while(count < (sizeof(adminCode) - 1)) {
    char adminCodeKey;
    do{
        adminCodeKey = keypad.getKey();//wait for a keypress
        }
     while(adminCodeKey == '\0');
   
   code = (code * 10) + (adminCodeKey - 48); //store correct digits for later use

 
  if(adminCodeKey == '#' && back == 0) {
              count = sizeof(adminCode);
              code = 0;
              exitMenu = 1;//bail out if # is pressed
              lcd.clear();
   }
 
   else {
     //if key matches code
         adminCode[count] = adminCodeKey;
              count++;
              back = 1;
            }
   

  selectLineOne();
    lcd.print("Code"); //prompt for arm code
   lcd.print(": ");
  lcd.print(code);
    }//end admincode while
    lcd.clear();
   
    selectLineOne();
    lcd.print(code);
    selectLineTwo();
    lcd.print("* to exit");//display new code and give user time to see it
    char key1;
      do{
        key1 = keypad.getKey(); 
        }
     while(key1 == '\0' || key1 != '*');//keep looping until user presses *
 
    break;
   
    case '2': //Timer
   
  lcd.clear();
  selectLineTwo();
  lcd.print("# To Exit");
  delay(2000);
  lcd.clear();
   
  char timeInt;
  selectLineOne();
  lcd.print("Enter Hours");
  do{
    timeInt = keypad.getKey();
      }
  while(timeInt == '\0' || timeInt < '0' || timeInt > '6');
 
  hour = (timeInt - '0') * 10;//get first digit and convert to int
  do{
    timeInt = keypad.getKey();
      }
  while(timeInt == '\0');
  hour = (timeInt - '0') + hour;//get second digit.
  lcd.clear();
  timeInt = 'L';
 
  lcd.print("Enter Minutes");
  do{
    timeInt = keypad.getKey();
      }
  while(timeInt == '\0' || timeInt < '0' || timeInt > '6');
  while (timeInt < '0' || timeInt > '6'){
    timeInt = keypad.getKey();
  }
  minute = (timeInt - '0') * 10;//get first digit and convert to int
  do{
    timeInt = keypad.getKey();
      }
  while(timeInt == '\0');
  minute = (timeInt - '0') + minute;//get second digit.
  lcd.clear();
  timeInt = 'L';
 
  lcd.print("Enter Seconds");
  do{
    timeInt = keypad.getKey();
      }
  while(timeInt == '\0' || timeInt < '0' || timeInt > '6');
  while (timeInt < '0' || timeInt > '6'){
    timeInt = keypad.getKey();
  }
  second = (timeInt - '0') * 10;//get first digit and convert to int
  do{
    timeInt = keypad.getKey();
      }
  while(timeInt == '\0');
  second = (timeInt - '0') + second;//get second digit.
  lcd.clear();
  timeInt = 'L';
 
  lcd.clear();
   
    selectLineOne();
    lcd.print(hour, DEC); // the hour, sent to the screen in decimal format
    lcd.print(":"); // a colon between the hour and the minute
    lcd.print(minute, DEC); // the minute, sent to the screen in decimal format
    lcd.print(":"); // a colon between the minute and the second
    lcd.print(second, DEC); // the second, sent to the screen in decimal format
   
    selectLineTwo();
    lcd.print("* to exit");
    char key2;
      do{
        key2 = keypad.getKey(); 
        }
     while(key2 == '\0' || key2!= '*');//display new code and give user time to see it
 
    break;
 
  case '3': //Arm code
  lcd.clear();
  selectLineTwo();
  lcd.print("# To Exit");
  delay(2000);
  lcd.clear();
 
   selectLineTwo();
   lcd.print("ArmCode");

   selectLineOne();
   lcd.print("Code"); //prompt for admin code
   lcd.print(": ");
   
     count = 0;
     code = 0;
     back = 0;
     
    while(count < (sizeof(ArmCode) - 1)) {
    char armCodeKey;
    do{
       armCodeKey = keypad.getKey();
        }
     while(armCodeKey == '\0');
   
   code = (code * 10) + (armCodeKey - 48);//store correct digits for later use

 
  if(armCodeKey == '#' && back == 0) {
              count = sizeof(ArmCode);
              code = 0;
              exitMenu = 1;
              lcd.clear();//bail out if exit key is pressed
     }
 
   else {
     //if key matches code
         ArmCode[count] = armCodeKey;
              count++;
              back = 1;
            }
   

  selectLineOne();
    lcd.print("Code"); //prompt for arm code
   lcd.print(": ");
  lcd.print(code);
    }//end armcode while
    lcd.clear();
   
    selectLineOne();
    lcd.print(code);
    selectLineTwo();
    lcd.print("* to exit");
    char key3;
      do{
        key3 = keypad.getKey(); //display new code and give user time to see it
        }
     while(key3 == '\0' || key3!= '*');
 
    break;
   
  case '4': //disarm
   lcd.clear();
  selectLineTwo();
  lcd.print("# To Exit");
  delay(2000);
  lcd.clear();
 
   selectLineTwo();
   lcd.print("disarmCode");

   selectLineOne();
   lcd.print("Code"); //prompt for admin code
   lcd.print(": ");
   
     count = 0;
     code = 0;
     back = 0;
     
    while(count < (sizeof(disarmCode) - 1)) {
    char disarmCodeKey;
    do{
       disarmCodeKey = keypad.getKey();
        }
     while(disarmCodeKey == '\0');
   
   code = (code * 10) + (disarmCodeKey - 48);

 
  if(disarmCodeKey == '#' && back == 0) {
              count = sizeof(disarmCode);
              code = 0;
              exitMenu = 1;
              lcd.clear();
     }
 
   else {
     
         disarmCode[count] = disarmCodeKey;
              count++;
              back = 1;
            }
   

  selectLineOne();
    lcd.print("Code"); //prompt for arm code
   lcd.print(": ");
  lcd.print(code);
    }//end disarmcode while
    lcd.clear();
   
    selectLineOne();
    lcd.print(code);
    selectLineTwo();
    lcd.print("* to exit");
    char key4;
      do{
        key4 = keypad.getKey();//display new code and give user time to see it 
        }
     while(key4 == '\0' || key4 != '*');
 
    break;
   
   case '#'://exit case
     exitMenu = 1;//exit menu if # is pressed
     break;
     
     case 'L'://exit case no admin code
     exitMenu = 1;
     break;
     
}//end switch

 }while(exitMenu == 0); //end menu while loop

configMenuFlag = 1;//set flag so menu cannot be opened later
saveConfig();//write new configuration into memory

}//end configMenu


/***********************************************************
* saves the admin code, arm code, disarm code, and timer   *
*  into EEPROM memory where they will survive a power down *
*                 saveConfig();                              *
************************************************************/

void saveConfig() {
 
  configuration.arm = atol(ArmCode);
  configuration.disarm = atol(disarmCode);
  configuration.admin = atol(adminCode);
  configuration.c_hour = hour;
  configuration.c_minute = minute;
  configuration.c_second = second;
 
  EEPROM_writeAnything(0, configuration);
 
}

/***********************************************************
* Reads the admin code, arm code, disarm code, and timer   *
*  from EEPROM memory and into local variables             *
*                 readConfig();                              *
************************************************************/

void readConfig() {
 
  EEPROM_readAnything(0, configuration);
 
  ltoa(configuration.arm, ArmCode, 10);
  ltoa(configuration.disarm,disarmCode,10);
  ltoa(configuration.admin,adminCode,10);
  hour = configuration.c_hour;
  minute = configuration.c_minute;
  second = configuration.c_second;
}

/***********************************************************
* chirps a buzzer at 3 different intervals  > 30 seconds   *
*  < 30 seconds, and < 10 seconds                          *
*                 beepSecondaryBuzzer()                    *
************************************************************/

void beepSecondaryBuzzer() {
 
 int timeLeft = 0;//default, seconds > 30
 
 if(hour == 0 && minute == 0 && second <= 30 && second > 10){
  timeLeft = 1; //if less than 30 seconds but more than 10 seconds left
 }
 
 else if (hour == 0 && minute == 0 && second <= 10 && second > 0){
  timeLeft = 2; //if less than 10 seconds left
 }
 
 switch(timeLeft){
 
  case 0:
    currentMillis = millis();
  if (currentMillis - previousTime > 60000)//1 minute interval
  {
    previousTime = currentMillis;
    previousDelay = currentMillis;
   
   digitalWrite(speakerPin, HIGH);//turn on buzzer
  }
 
  if (currentMillis - previousDelay > 100) {//100ms chirp duration
    digitalWrite(speakerPin, LOW);//turn off buzzer
  }
  break;
 
  case 1:
 
  currentMillis = millis();
  if (currentMillis - previousTime > 2000)// 2 second interval
  {
    previousTime = currentMillis;
    previousDelay = currentMillis;
   
   digitalWrite(speakerPin, HIGH);//turn on buzzer
  }
 
  if (currentMillis - previousDelay > 100) {//100ms chirp duration
    digitalWrite(speakerPin, LOW);//turn off buzzer
  }
 
  break;
 
  case 2:
 
  currentMillis = millis();
  if (currentMillis - previousTime > 500)// 1/2 second interval
  {
    previousTime = currentMillis;
    previousDelay = currentMillis;
   
   digitalWrite(speakerPin, HIGH);//turn on buzzer
  }
 
  if (currentMillis - previousDelay > 100) {//100ms chirp duration
    digitalWrite(speakerPin, LOW);//turn off buzzer
  }
 
  break;
 
 }//end case statement
 
}//end beepSecondaryBuzzer();



Graag uw mening of antwoord, zit echt potvast op dit moment.

Advertisement

Gebruikers-avatar
Berichten: 5043
Geregistreerd: 13 Mei 2013, 20:57
Woonplaats: Heemskerk

Re: arduino bomb prop code probleem, help aub !!

Berichtdoor nicoverduin » 04 Okt 2013, 17:00

Heb al eens overwogen Serial toe te voegen om te kijken wat de waardes zijn? M.a.w. om te vinden waar het fout gaat?
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Gebruikers-avatar
Berichten: 5043
Geregistreerd: 13 Mei 2013, 20:57
Woonplaats: Heemskerk

Re: arduino bomb prop code probleem, help aub !!

Berichtdoor nicoverduin » 04 Okt 2013, 17:15

Loopt dit wel goed?
Code: Alles selecteren
   case ARMED:

      selectLineOne();
      lcd.print("Code"); //prompt for disarm code
      lcd.print(": ");

      char key;
      do {
         key = keypad.getKey();
         countdown(); //displays countdown while simultaneously checking for disarm code

         if (second == 0 && minute == 0 && hour == 0) {
            code = 0;
            lcd.clear();
            bombState = DETONATED; //clear LCD and set bomb state to "detonated" when timer runs out
            break;
         }
         //if the correct code is entered, move to disarmed state
         else if (count == (sizeof(disarmCode) - 1)) {
            code = 0;
            lcd.clear();
            bombState = DISARMED;
         }

      } //end do
      while (key == '\0' && bombState == ARMED);

      code = (code * 10) + (key - 48); //store correct digits for display later

      //if the key entered matches the disarm code, increase count.
      if (key == disarmCode[count]) {
         count++;
      }

      else {
         count = 0;
         code = 0;
         lcd.clear();
      }

      selectLineOne();
      lcd.print("Code"); //prompt for arm code
      lcd.print(": ");
      lcd.print(code); //display the current correct digits

      break;
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Berichten: 6
Geregistreerd: 04 Okt 2013, 15:22

Re: arduino bomb prop code probleem, help aub !!

Berichtdoor silentwolf » 04 Okt 2013, 23:49

nicoverduin schreef:Heb al eens overwogen Serial toe te voegen om te kijken wat de waardes zijn? M.a.w. om te vinden waar het fout gaat?


Is dat mogelijk als ik geen serial lcd heb of heeft dat geen belang?

Ik zit nog maar pas in het arduino gebeuren dus echt veel weet ik er niet van..

Berichten: 6
Geregistreerd: 04 Okt 2013, 15:22

Re: arduino bomb prop code probleem, help aub !!

Berichtdoor silentwolf » 04 Okt 2013, 23:53

nicoverduin schreef:Loopt dit wel goed?
Code: Alles selecteren
   case ARMED:

      selectLineOne();
      lcd.print("Code"); //prompt for disarm code
      lcd.print(": ");

      char key;
      do {
         key = keypad.getKey();
         countdown(); //displays countdown while simultaneously checking for disarm code

         if (second == 0 && minute == 0 && hour == 0) {
            code = 0;
            lcd.clear();
            bombState = DETONATED; //clear LCD and set bomb state to "detonated" when timer runs out
            break;
         }
         //if the correct code is entered, move to disarmed state
         else if (count == (sizeof(disarmCode) - 1)) {
            code = 0;
            lcd.clear();
            bombState = DISARMED;
         }

      } //end do
      while (key == '\0' && bombState == ARMED);

      code = (code * 10) + (key - 48); //store correct digits for display later

      //if the key entered matches the disarm code, increase count.
      if (key == disarmCode[count]) {
         count++;
      }

      else {
         count = 0;
         code = 0;
         lcd.clear();
      }

      selectLineOne();
      lcd.print("Code"); //prompt for arm code
      lcd.print(": ");
      lcd.print(code); //display the current correct digits

      break;


Geen idee, ik kan geen codes ingeven, zowel de armcode als de admin code kan ik niet ingeven. Zodra ik een cijfer ingeef met het keypad verschijnt er enkel 1 nul, zelfs als ik meerdere cijfers ingeef, het blijft bij 1 "0" karakter..

Gebruikers-avatar
Berichten: 5043
Geregistreerd: 13 Mei 2013, 20:57
Woonplaats: Heemskerk

Re: arduino bomb prop code probleem, help aub !!

Berichtdoor nicoverduin » 05 Okt 2013, 00:11

Dan zou ik eerst eens beginnen met Serial in te bouwen zodat je kan zien wat er uit je keypad komt. en dan stap voor stap uitbouwen. Dan kan je het proces volgen
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Berichten: 6
Geregistreerd: 04 Okt 2013, 15:22

Re: arduino bomb prop code probleem, help aub !!

Berichtdoor silentwolf » 05 Okt 2013, 15:36

Ik zou wel willen maar heb totaal geen ervaring met serials..

Gebruikers-avatar
Berichten: 5043
Geregistreerd: 13 Mei 2013, 20:57
Woonplaats: Heemskerk

Re: arduino bomb prop code probleem, help aub !!

Berichtdoor nicoverduin » 05 Okt 2013, 15:55

In de setup:
Serial.begin(9600);


En dan in de code als je een variable het gezet

Serial.print(variabele);
of
Serial.println(variabele); // dan spring hij gelijk daarna naar een nieuwe regel

In de Arduino IDE start je EXTRA-> SERIELE MONITOR

En dan opent hij een seriele terminal met de Arduino en zie je de waardes uit Serial.print etc op je scherm .

Zie verder: http://arduino.cc/en/Reference/Serial
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Berichten: 6
Geregistreerd: 04 Okt 2013, 15:22

Re: arduino bomb prop code probleem, help aub !!

Berichtdoor silentwolf » 15 Okt 2013, 17:26

volgens de seriele methode werkt alles, alle "keys" (variabele) worden herkend en als juist doorgegeven. Het is precies of hij alles omzet in een 0 en geen getal bijvoegt. Zo lijkt het maar ik denk niet dat het zo werkelijk is...

Gebruikers-avatar
Berichten: 5043
Geregistreerd: 13 Mei 2013, 20:57
Woonplaats: Heemskerk

Re: arduino bomb prop code probleem, help aub !!

Berichtdoor nicoverduin » 15 Okt 2013, 18:23

zou je ff de laatste versie willen geven van de code inclusief de serial code?
Docent HBO Technische Informatica, Embedded ontwikkelaar & elektronicus
http://www.verelec.nl

Volgende

Terug naar C code

Wie is er online?

Gebruikers in dit forum: Geen geregistreerde gebruikers en 21 gasten