当前位置: 动力学知识库 > 问答 > 编程问答 >

c - RFID MF522 13,56 MHz and LCD Keypad Shield Arduino Issue in Arduino Mega 2560

问题描述:

I'm working a project using Arduino Mega 2560, LCD Keypad Shield, and RFID 13,56 MHz MF522 module.

The problem is that the LCD Keypad shield and RFID MF522 are using pin 5 together, so I changed RFID pin to the other digital pin (I'm using pin 31 now). But when I initialize the RFID and LCD shield, the LCD is not working. When I don't initialize the RFID, the LCD shield working well.

I'm using the LiquidCrystal library for the LCD, and RFID library made by Miguel Balboa (circuitito.com) based on code by Dr.Leong (www.b2cqshop.com).

Here's some simple code I've made :

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

RFID rfid(53,31); //when init RFID, pin 5 changed to 31

void setup()

{

Serial.begin(9600);

analogWrite(10, 50); // set brightness on pin 10 to 0-255

lcd.begin(16, 2); // start the library

rfid.init(); //when RFID init, LCD not working

}

void loop()

{

lcd.setCursor(9,1); // move cursor to second line "1" and 9 spaces over

lcd.print(millis()/1000); // display seconds elapsed since power-up

}

Any suggestion to make the LCD shield work together with the RFID module? Or am I doing something wrong?

Note :

I've tried using just the RFID using pin 31 without init the LCD, and the RFID is working well.

网友答案:

Ohh, I've got the answer by myself.. I'm just forget to add the SPI. At the setup, just add SPI.begin() and now my LCD and RFID can work together.

Here's the setup :

void setup()
{
     Serial.begin(9600);
     SPI.begin();
     rfid.init();
     analogWrite(10, 50); // set brightness on pin 10 to 0-255
     lcd.begin(16, 2);              // start the library
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: