arduino uno 加pn532模块 nfc 控制电机 报错^~~~ exit status 1 stray '#...-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 2224|回复: 2

[未解决] arduino uno 加pn532模块 nfc 控制电机 报错^~~~ exit status 1 stray '#...

[复制链接]
发表于 2021-1-27 23:57 | 显示全部楼层 |阅读模式
用的示例改动的 一直报错
求助大佬们帮萌新看下哪里出了问题
感激不尽

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>

#include <Servo.h>
Servo myservo;

// If using the breakout or shield with I2C, define just the pins connected
// to the IRQ and reset lines.  Use the values below (2, 3) for the shield!
#define PN532_IRQ   (2)
#define PN532_RESET (3)  // Not connected by default on the NFC Shield

// Uncomment just _one_ line below depending on how your breakout or shield
// is connected to the Arduino:

// Use this line for a breakout with a hardware SPI connection.  Note that
// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
// hardware SPI SCK, MOSI, and MISO pins.  On an Arduino Uno these are
// SCK = 13, MOSI = 11, MISO = 12.  The SS line can be any digital IO pin.
//Adafruit_PN532 nfc(PN532_SS);

// Or use this line for a breakout or shield with an I2C connection:
Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);

void setup(void) {

  myservo.attach(9);
  myservo.write(90)

  Serial.begin(115200);
  while (!Serial) delay(10); // for Leonardo/Micro/Zero

  Serial.println("Hello!");

  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }
  // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);

  // configure board to read RFID tags
  nfc.SAMConfig();

  Serial.println("Waiting for an ISO14443A Card ...");
}


void loop(void) {
  uint8_t success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
  uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

  // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found
  // 'uid' will be populated with the UID, and uidLength will indicate
  // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);

  if (success) {
    // Display some basic information about the card
    Serial.println("Found an ISO14443A card");
    Serial.print("  UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
    Serial.print("  UID Value: ");
    nfc.PrintHex(uid, uidLength);

    if (uidLength == 4)
    {
      // We probably have a Mifare Classic card ...
      uint32_t cardid = uid[0];
      cardid <<= 8;
      cardid |= uid[1];
      cardid <<= 8;
      cardid |= uid[2];  
      cardid <<= 8;
      cardid |= uid[3];
      Serial.print("Seems to be a Mifare Classic card #");
      Serial.println(cardid);
      if(cardid=#203765528 ||cardid =#203765528 );
      {myservo.write(90);
      delay(2000);
      myservo.write(90);
      }
    }
    Serial.println( );
    if(uidLength = 7)
    {
      uint32_t  cardid1 = uid[1];
      cardid1 <<=8;
      cardid1 |= uid[2];
      Serial.print("Seems to be a NFC tag card #");
      Serial.println(cardid1);
      if(cardid1 =#9527 ||cardid1 =#9527 );
      {myservo.write(90);
      delay(2000);
      myservo.write(90);
      }

    }
    Serial.println("");
  }
}


发表于 2021-1-28 13:15 | 显示全部楼层
报错的具体内容是啥
发表于 2021-1-29 04:21 | 显示全部楼层
有需要可以有偿定制程序,另外这个代码是我18还19年写的,并不适合直接使用
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-29 13:33 , Processed in 0.079959 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表