---------------------------------

Freaduino mega 2560 

rc522 & arduino lib 下载地址: https://github.com/miguelbalboa/rfid

----------------------------------

现象:

[Arduino] 驱动RC522 读取 UID例程

 

-------------------------------------------codeStart------------------------------

 1 /************************************************
 2 *@: main.h
 3 *@: rc522 Module
 4 *@: Hmily 
 5 *@: 2014.10.31 15:44:58 Version 1.0
 6 ************************************************/
 7 
 8 //*****************************************************************************************
 9 //@:Header files included
10 //*****************************************************************************************
11 #if defined(ARDUINO) && ARDUINO >= 100
12     #include "Arduino.h"
13 #else
14     #include "WProgram.h"
15 #endif
16 #include <SPI.h>
17 #include <MFRC522.h>
18 
19 #ifndef     __MAIN_H__
20 #define        __MAIN_H__
21     
22     // board type
23     #define BOARD_TYPE_ARDUINO_NANO                    0x01
24     #define BOARD_TYPE_ARDUINO_MEGA                    0x02
25     #define BOARD_TYPE_ARDUINO_MEGA_2560            BOARD_TYPE_ARDUINO_MEGA
26     
27     #define BOARD_TYPE                                BOARD_TYPE_ARDUINO_MEGA
28     #define DEBUG_MODE                                1
29     
30     // type definition 
31     #define uint_8         unsigned char
32     #define sint_8         signed char
33     #define uint_16     unsigned short int
34     #define sint_16     signed short int 
35     
36     // pin distribution 
37     #if BOARD_TYPE == BOARD_TYPE_ARDUINO_MEGA
38         // *****for BOARD_TYPE_ARDUINO_MEGA_2560 & BOARD_TYPE_ARDUINO_MEGA  
39         // http://arduino.cc/en/Main/ArduinoBoardMega2560
40         // rc522 spi interface
41         #define PIN_RC522_CS            53    //SPI_SS default
42         #define PIN_RC522_SCK            52
43         #define PIN_RC522_MISO            50    
44         #define PIN_RC522_MOSI            51
45         #define PIN_RC522_RST            49
46     #else 
47         // *****for BOARD_TYPE_ARDUINO_NANO  
48         //http://arduino.cc/en/Main/ArduinoBoardNano
49         // rc522 spi interface
50         #define PIN_RC522_CS            10    //SPI_SS default
51         #define PIN_RC522_SCK            13
52         #define PIN_RC522_MISO            12    
53         #define PIN_RC522_MOSI            11
54         #define PIN_RC522_RST            9
55         
56     #endif // end of switch(BOARD_TYPE)
57 
58 #endif // end of __MAIN_H__
main.h

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2021-12-16
  • 2022-02-07
  • 2022-12-23
  • 2021-04-02
  • 2022-01-31
猜你喜欢
  • 2021-04-07
  • 2022-12-23
  • 2021-11-23
  • 2021-12-05
  • 2021-11-14
  • 2023-03-02
  • 2022-01-21
相关资源
相似解决方案