Cần giúp về lỗi của Arduino

Em xin cám ơn vì đã giúp trước ạ
về phần lỗi là

Arduino: 1.8.3 (Windows 10), Board: "Arduino/Genuino Uno"

Arduino: 1.8.3 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\eNViDAT\AppData\Local\Temp\arduino_modified_sketch_392389\DumpInfo.ino: In function 'void setup()':

DumpInfo:21: error: expected ')' before ';' token

   pinMode(redLed; OUTPUT);

                 ^

DumpInfo:21: error: expected ';' before ')' token

   pinMode(redLed; OUTPUT);

                         ^

DumpInfo:22: error: expected ')' before ';' token

   pinMode(greenLed; OUTPUT);

                   ^

DumpInfo:22: error: expected ';' before ')' token

   pinMode(greenLed; OUTPUT);

                           ^

DumpInfo:23: error: expected ')' before ';' token

   pinMode(blueLed; OUTPUT);

                  ^

DumpInfo:23: error: expected ';' before ')' token

   pinMode(blueLed; OUTPUT);

                          ^

C:\Users\eNViDAT\AppData\Local\Temp\arduino_modified_sketch_392389\DumpInfo.ino: In function 'void loop()':

DumpInfo:59: error: expected ')' before ';' token

     digitalWrite(blueLed; High);

                         ^

DumpInfo:59: error: 'High' was not declared in this scope

     digitalWrite(blueLed; High);

                           ^

DumpInfo:69: error: 'redLED' was not declared in this scope

     digitalWrite(redLED; High);

                  ^

DumpInfo:69: error: 'High' was not declared in this scope

     digitalWrite(redLED; High);

                          ^

exit status 1
expected ')' before ';' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

còn phần code của em là

*/

#include <SPI.h>
#include <MFRC522.h>
 
#define SS_PIN 10
#define RST_PIN 9
constexpr uint8_t redLed = 5;   // Set Led Pins
constexpr uint8_t greenLed = 6;
constexpr uint8_t blueLed = 7;
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
 
void setup() 
{
  pinMode(redLed; OUTPUT);
  pinMode(greenLed; OUTPUT);
  pinMode(blueLed; OUTPUT);
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  Serial.println("Nhap the");
  Serial.println();

}
void loop() 
{
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent()) 
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  {
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) 
  {
     Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
     Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  if (content.substring(1) == "56 78 2C 07") //Mã thẻ uid ( thay thế)
  {
    Serial.println("Truy cap du lieu");
    Serial.println();
    digitalWrite(blueLed; HIGH); //Lỗi ở đây
    delay(3000);
  }
 
 else   {
    Serial.println(" Access denied");
    digitalWrite(greenLed; HIGH); // Đây nữa
    delay(3000);
  }
}

Chắc bạn viết code nhiều quá nên nhầm lẫn giữa ,; trong tham số của hàm :smile:

1 Like

Lỗi có trong log hết rồi mà bạn không chịu đọc thôi.

  1. Bạn bị nhầm lần giữa dấu chấm phẩy dùng để kết thúc một lệnh với dấu phẩy để tach nhau giữa các biến trong lời gọi hàm.
  2. Các biến High, redLED => Biến chưa được khai báo. Trong code không lỗi nhưng trên log bạn nhầm lẫn giữa chữ hoa với chữ thường.
1 Like

Cám ơn rất nhiều ạ, ai ngờ lỗi đơn giản như thế lại quên

1 Like
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?