Go Down

Topic: Arduino and Keypad (Read 557 times) previous topic - next topic

iArcane

Hey Paul,

Thanks for your reply! It is very  helpful. As you can tell I'm fairly new to Arduino, but I shall try the things you mentioned and post a reply with my results! I left that comment there in the RFID so my colleague can tell which bits need tweaking. We mapped the value from 0 to 1023 to 0 to 5 so we get a better idea of true voltage. Our RFID seems a bit sketchy, and outputs 5v when alone and 1-2v when a tag is near, which explains the if statement.

Also for the serial begin, I'm using Analog 5 for the RFID data input, and the same pin as Digital 19 for the Servo motor output due to a lack of pins on the board. That is why I put the Serial call in that function, so it would not overwrite declaring it as a digital pin later in the code. Any idea if that is possible or will work?

Everything else seems obvious to me now. I apologise, had a lack of sleep trying to get this working. Will post my results later today! Thanks again Paul!


The loop() function calls waiting(). The waiting() function may call loop(). Does that really seem like a good idea?

The correctpin() function calls loop(). Not a good idea, either.

Code: [Select]
  if (RFID < 2)                      // CODE FOR RFID ANALOG VALUE. NEEDS TWEAKING

No kidding. Does RFID mean something different from the usual meaning of the term?

Code: [Select]
  Serial.begin(9600);
This belongs in setup(), so it is called once, not in pincode() where it is called bazillions of times.

Code: [Select]
  char key= kpd.getKey();
Serial.print(key);
{

Probably ought to check that a key was pressed, before printing it... What's the { for?

Looking at your code, I think that last statement is really the key to your problem. You never test that a key was pressed, so pincode() blasts through and returns many, many times before you get one key pressed.

Code: [Select]
    if (i == 1) //if 1 press has been made
    {
      GLCD.DrawBitmap(pin1, 0,0, BLACK);
    }
   
    if (i == 2) //if 2 presses have been made
    {
      GLCD.DrawBitmap(pin2, 0,0, BLACK);
    }

If i is 1, can it also be 2, 3, or 4? You need some elses in this function.

PaulS

Quote
Our RFID seems a bit sketchy, and outputs 5v when alone and 1-2v when a tag is near, which explains the if statement.

What RFID reader do you have? It is most likely trying to toggle the pin to send you data. You need to be reading that data far differently than you currently are.

Quote
I'm using Analog 5 for the RFID data input, and the same pin as Digital 19 for the Servo motor output due to a lack of pins on the board. That is why I put the Serial call in that function, so it would not overwrite declaring it as a digital pin later in the code.

Analog pin 5/digital pin 19 usage has nothing to do with the serial port initialization or pins. Put Serial.begin() where it belongs - in setup().

iArcane

Great, thanks for the advice. I seem to have got the column working now. I have programmed numbers 1, 4 and 7. 1 and 4 are printing as expected however when I press 7 it prints "741" to the screen. I assume there might be a short circuit on the keypad. Will run a continuity test on a voltmeter and reply later.

The RFID we have uses a form of Manchester decoding to convert the signal to 1 state or another. As we got it off ebay, we got very limited information. I can't remember the chip name (Will try and dig up the datasheet if necessary) but after several nights of googling we couldn't find much out about decoding the signal. Because of that we are converting the volt reading into an analog signal in Arduino and using that as a value, abusing the fact that it reduces the voltage when a tag is near. We aren't too bothered about utilising the unique tag as this is a prototype model and we are hoping to spend more time later decoding the signal, however we do have a deadline approaching.

Thanks again for your help so far Paul


Quote
Our RFID seems a bit sketchy, and outputs 5v when alone and 1-2v when a tag is near, which explains the if statement.

What RFID reader do you have? It is most likely trying to toggle the pin to send you data. You need to be reading that data far differently than you currently are.

Quote
I'm using Analog 5 for the RFID data input, and the same pin as Digital 19 for the Servo motor output due to a lack of pins on the board. That is why I put the Serial call in that function, so it would not overwrite declaring it as a digital pin later in the code.

Analog pin 5/digital pin 19 usage has nothing to do with the serial port initialization or pins. Put Serial.begin() where it belongs - in setup().

Go Up