Show Posts
Pages: 1 [2]
16  Forum 2005-2010 (read only) / Syntax & Programs / Re: Scrolling menu program hangs... on: May 20, 2010, 05:39:37 am
hi everyone

I have added some serial debug lines and it appears to jump from 22a to 31 then to 38 and hang there..

Code:
void LCDclear(){
  LCDserial.print(0xFE, BYTE);      
  LCDserial.print(0x01, BYTE);
}

void LCDfirst(){
  LCDserial.print(0xFE, BYTE);
  LCDserial.print(128, BYTE);
}
void LCDsecond(){
  LCDserial.print(0xFE, BYTE);
  LCDserial.print(192, BYTE);
}

void menu() {
  Serial.println(" 1");
  while(digitalRead(up) == HIGH or digitalRead(down) == HIGH or digitalRead(select) == HIGH){};
  Serial.println(" 2");
  delay(50);
  Serial.println(" 3");
  LCDclear();
  Serial.println(" 4");
  LCDfirst();
  Serial.println(" 5");
  if(prognumber > 1){
    Serial.println(" 6");    
  prognumber--;
  Serial.println(" 7");
  }
  else{
    Serial.println(" 8");
    prognumber == 1;
  Serial.println(" 9");
  }
  LCDmenudisplay();
  Serial.println(" 10");
  LCDsecond();
  Serial.println(" 11");

  prognumber++;
Serial.println("12 ");
  LCDmenudisplay();
  Serial.println("13 ");
  if(line == 1){
    Serial.println("14 ");
    LCDserial.print(0xFE, BYTE);
    Serial.println("15 ");
    LCDserial.print(143, BYTE);
    Serial.println(" 16");
    LCDserial.print("<");
    Serial.println("17 ");
  }
  else {
    Serial.println("18 ");
    LCDserial.print(0xFE, BYTE);
    Serial.println("19 ");
    LCDserial.print(207, BYTE);
    Serial.println("20 ");
    LCDserial.print("<");
    Serial.println(" 21");
  }
   Serial.println("22A ");
  while(digitalRead(up) == LOW && digitalRead(down) == LOW && digitalRead(select) == LOW){}
  Serial.println("22 ");
  delay(50);
  if(digitalRead(down) == HIGH){
    Serial.println(" 23");
  line++;
  Serial.println("24 ");
  if(line > 2){
    Serial.println("25 ");
  line = 2;
  Serial.println(" 26");
  prognumber++;
  Serial.println("27 ");
  }
  if(prognumber > 4){
    Serial.println("28 ");
  prognumber = 5;
Serial.println(" 29");
  }
  Serial.println(" 30");
  menu();
  Serial.println(" 31");
  }
  delay(50);
  if(digitalRead(up) == HIGH){
    Serial.println("32 ");
  line--;
  Serial.println("33 ");
  if(line < 1){
    Serial.println("34 ");
  line = 1;
  Serial.println("35 ");
  prognumber--;
  Serial.println("36 ");
  }
  Serial.println(" 37");
  menu();
  Serial.println("38 ");
  }
  delay(50);
  if(digitalRead(select) == HIGH){
    Serial.println("39 ");
  if(line == 1){
    Serial.println(" 40");
    prognumber--;
    Serial.println("41 ");
  }
  Serial.println("42 ");
  switch (prognumber) {                  
  case 1:                                
Serial.println("43 ");
    first();
    break;                              
  case 2:
  Serial.println("44 ");
    second();
    break;
  case 3:
  Serial.println("45 ");
    third();
    break;
  case 4:
  Serial.println("46 ");
    fourth();
    break;
  case 5:
  Serial.println("47");
    fifth();
    break;
   default:
    Serial.println("48");
    first();
      break;
  }
  }
}

void LCDmenudisplay() {
  switch (prognumber) {                  
  case 1:                                
    LCDserial.print("First");  
    break;                              
  case 2:
    LCDserial.print("Second");
    break;
  case 3:
    LCDserial.print("Third");
    break;
  case 4:
    LCDserial.print("Fourth");
    break;
  case 5:
    LCDserial.print("Fifth");
    break;
  default:
    LCDserial.print("First");
  }
  
}

void first() {
  digitalWrite(13, HIGH);
  menu();
}

void second() {
  menu();
}

void third() {
  menu();
}

void fourth() {
  menu();
}

void fifth() {
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  menu();
}
any ideas????

thanks heaps

ben
17  Forum 2005-2010 (read only) / Syntax & Programs / Re: RF Link 4800bps Receiver & Transmitter on: June 13, 2010, 10:23:44 pm
i have been doing some research and virtualwire library should work.

What do u guys think?

ben
18  Forum 2005-2010 (read only) / Syntax & Programs / Re: RF Link 4800bps Receiver & Transmitter on: June 13, 2010, 05:51:06 pm
thats what I thought I would have to do but I can only send 0 to 255(i think??)

so how do I set up a header and tail??

thanks

ben
19  Forum 2005-2010 (read only) / Syntax & Programs / RF Link 4800bps Receiver & Transmitter on: June 13, 2010, 07:01:50 am
Hi,
I purchased a RF Link 4800bps Receiver & Transmitter from spark fun.

I have it working perfectly except how do you determine when the transmitter is powered up and wait until it has established a link with the receiver before running any code on the receiver?

Code:
void loop(){
incomingByte = rfSerial.read();
 Serial.println(incomingByte, DEC);

 if(incomingByte <30){
    digitalWrite(red, HIGH);
    digitalWrite(blue, LOW);
    digitalWrite(green, LOW);
  }
  else if(incomingByte >30 && incomingByte <40){
    digitalWrite(blue, HIGH);
    digitalWrite(red, LOW);
    digitalWrite(green, LOW);
  }
    else if(incomingByte >40){
    digitalWrite(green, HIGH);
    digitalWrite(red, LOW);
    digitalWrite(blue, LOW);
  }

incomingByte = 0;

}
Im thinking Ill need to have some sort of system i.e

send 000011000011000011 at start up then look for that at the other end????

I really have no idea!!!

thanks

thanks

Ben
20  Forum 2005-2010 (read only) / Interfacing / Re: Keypad Troubles on: January 02, 2010, 09:33:19 am
Ok I Finally go the code working....just 1 little bug

once you enter the correct code
then next code you enter has additional garbage with the code

code below

then serial output

Code:
#include <Keypad.h>
#define VERSION "V0.5 Jan2010"

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
int i = 0;
char code[5] = {0, 0, 0, 0, 0};
boolean correctCombo = false;


// 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] = {12, 11, 10 };

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

#define ledpin 13

void setup()
{

  digitalWrite(ledpin, HIGH);
  Serial.begin(9600);
  Serial.println("DOOR SECURITY ONLINE");
  Serial.println(VERSION);
}

void loop()
{

  if (i == 5){
  check();
  }
  char key = kpd.getKey();
  if(key)  
  {
    code[i] = key;
    i++;
  }
}

void check()
{
 Serial.println(code);
  if (strcmp(code, "12345") == 0){  
        Serial.println("Correct code");
        correctCombo = true;
        i = 0;
        
      }
      else
      {
        Serial.println("Wrong code");
        correctCombo = false;
        i = 0;
      }
 }




12345
Correct code
12345Uae4
Wrong code
21  Forum 2005-2010 (read only) / Interfacing / Re: Keypad Troubles on: January 02, 2010, 08:06:11 am
ok I have found the problem

I need to join variables together highlighted below in the foowing code

Code:
#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
int i = 0;
char code[5] = {
  0, 0, 0, 0, 0};
char correct[5] = {
  1, 2, 3, 4, 5};
boolean correctCombo = false;
char fcode;
int ccode = (12345);
int score;


// 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] = {
  12, 11, 10 };

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

#define ledpin 13

void setup()
{
  digitalWrite(ledpin, HIGH);
  Serial.begin(9600);
}

void loop()
{
  char key = kpd.getKey();
  if(key)  // same as if(key != NO_KEY)
  {
    code[i] = key;
    //Serial.println(key);
    if (i == 5){
      for (int p = 0; p < 5; p++) {
        [glow]fcode = fcode & code[p];[/glow]        
      }
      Serial.println(fcode);
      
      if (fcode == ccode){

        Serial.println("Correct code");
        fcode = 0;
        i = 0;
      }
      else
      {
        Serial.println("Wrong code");
        fcode = 0;
        i = 0;
      }
    }
    else{
      Serial.println(code[i]);
      i++;
    }
  }
}





thanks

Ben
22  Forum 2005-2010 (read only) / Interfacing / Re: Keypad Troubles on: January 02, 2010, 06:08:36 am
I have come up with the following code but it still says wrong code..


Can anyone please help.

Code:
#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
int i = 0; //(variable to keep track of number of keys pressed);
char code[5] = {0, 0, 0, 0, 0};
char correct[5] = {1, 2, 3, 4, 5};
boolean correctCombo = false;


// 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] = { 12, 11, 10 };

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

#define ledpin 13

void setup()
{
  digitalWrite(ledpin, HIGH);
  Serial.begin(9600);
}

void loop()
{
  char key = kpd.getKey();
  if(key)  // same as if(key != NO_KEY)
  {
         code[i] = key;
        //Serial.println(key);
        if (i == 5){
          check();
          
         }
         else{
          
        Serial.println(code[i]);
          
          i++;
         }
    
  }
}

void check()
{
  
  for (int i = 0; i < 5; i++) {
  if (code[i] != correct[i]){
  i = 5;
  correctCombo = false;
  Serial.println("Wrong code");
  break;
  }
  else
 {
    Serial.println("Correct code");
    
  }
  
  
}
}


Thanks

Ben
23  Forum 2005-2010 (read only) / Interfacing / Re: Keypad Troubles on: January 02, 2010, 01:41:51 am
thanks for your help at such a late time!!!

I will keep playing

talk to you later
24  Forum 2005-2010 (read only) / Interfacing / Re: Keypad Troubles on: January 02, 2010, 12:55:26 am
this is what I have done but still doesn't seem to work could you have a look TchnclFl..

Thanks

Code:
#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
int i = 0; //(variable to keep track of number of keys pressed);
int key[5] = {0, 0, 0, 0, 0};
int correct[5] = {1, 2, 3, 4, 5}; //(the correct combo)
boolean correctCombo = false; //(make a boolean to store whether the correct code is entered)

// 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] = { 12, 11, 10 };

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

#define ledpin 13

void setup()
{
  digitalWrite(ledpin, HIGH);
  Serial.begin(9600);

}

void loop()
{
  if (correctCombo == false) {
    if(key)  // same as if(key != NO_KEY)
    key[i] = kpd.getKey();
    i++;
    if ( i == 5) { //(check if you've entered 5 numbers)
    for (int i = 0; i < 5; i++) {
    if (key[i] != correct[i]) { //(compare the key to the corect combo
      i = 5; //(terminate the for loop)
      correctCombo = false; //(state that the combo isn't correct)
      Serial.println("wrong");
      
    }
    else {
      Serial.println("correct");
  }
}
}


i = 0;
}

}

25  Forum 2005-2010 (read only) / Interfacing / Re: Keypad Troubles on: January 01, 2010, 10:11:30 pm
thanks heaps i will give it a go ;D
26  Forum 2005-2010 (read only) / Interfacing / Keypad Troubles on: January 01, 2010, 08:47:37 pm
Hi I am using a keypad to unlock an electric door strike.

I have the door strike circuit working and the keypad is displaying the current button press by serial.

The problem is I need to save each keypress to an array up to 5 keypress's long, once it has 5 press's is check to see if the code is correct. I just cant work out how to do the array.

any help would be very appriciated.

Thanks

Ben
27  Forum 2005-2010 (read only) / Exhibition / Re: fingerprint home access system w/ info lcd and sms on: May 25, 2010, 11:55:14 pm
Hey please show us your project!! ;D
Pages: 1 [2]