Arduino Compilation error: Error: 2 UNKNOWN: no FQBN provided

Hi,

I am trying to upload code to my Arduino Uno board, however in the Arduino itself I am getting the error Compilation error: Error: 2 UNKNOWN: no FQBN provided.

 Compilation error: Error: 2 UNKNOWN: no FQBN provided

The code is below. This is code took from the internet which seemed to have worked for many other people.
I tried to verify the code from the examples in the Arduino and I am getting the same error code.
I assume it is nothing to do with the code, rather the Arduino software itself.
if anyone can help I would appreciate it.
Thanks in advance.

[code]
void setup() {
  int ledPin = 13;
int pirPin = 9;
int val = 0;
void setup()
{
  pinMode(ledPin, OUTPUT);
  pinMode(pirPin, INPUT);
}
void loop()
{
  val = digitalRead(pirPin);
  digitalWrite(ledPin, val);

if (val ==1)
  digitalWrite(ledPin, LOW);
}// put your setup code here, to run once:

}

[/code]

Hi @kajraj14. This error occurs when you have not selected a board. Unlike the classic Arduino IDE, the Arduino IDE 2.x does not have any boards selected on startup. There is also currently a bug that causes the board selection to be forgotten every time you open a new sketch.

So you only need to select Tools > Board > Arduino AVR Boards > Arduino Uno. After that, you'll be able to compile and upload.

Please let me know if you have any problems after doing that.

Hi thanks for your reply, that hasn't resolved it, unfortunately.
now I am getting an error stated below.
i am new to arduino, so could be something silly.

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

Pir_sensor_v1:3:13: error: expected ')' before ';' token

int led = 13;

^

C:\Users\user\Documents\Arduino\Pir_sensor_v1\Pir_sensor_v1.ino: In function 'void setup()':

Pir_sensor_v1:12:10: error: 'led' was not declared in this scope

pinMode(led, OUTPUT);

^~~

Pir_sensor_v1:14:2: error: 'serial' was not declared in this scope

serial.begin(9600) // put youPr setup code here, to run once:

^~~~~~

C:\Users\user\Documents\Arduino\Pir_sensor_v1\Pir_sensor_v1.ino:14:2: note: suggested alternative: 'Serial'

serial.begin(9600) // put youPr setup code here, to run once:

^~~~~~

Serial

C:\Users\user\Documents\Arduino\Pir_sensor_v1\Pir_sensor_v1.ino: In function 'void loop()':

Pir_sensor_v1:19:11: error: 'DigitalRead' was not declared in this scope

value = DigitalRead(pin)

^~~~~~~~~~~

C:\Users\user\Documents\Arduino\Pir_sensor_v1\Pir_sensor_v1.ino:19:11: note: suggested alternative: 'digitalRead'

value = DigitalRead(pin)

^~~~~~~~~~~

digitalRead

Pir_sensor_v1:28:2: error: 'else' without a previous 'if'

}else

^~~~

Pir_sensor_v1:30:14: error: 'led' was not declared in this scope

digitalWrite(led, LOW);

^~~

Pir_sensor_v1:33:3: error: 'serial' was not declared in this scope

serial.printIn ("Motion Ended!");

^~~~~~

C:\Users\user\Documents\Arduino\Pir_sensor_v1\Pir_sensor_v1.ino:33:3: note: suggested alternative: 'Serial'

serial.printIn ("Motion Ended!");

^~~~~~

Serial

Pir_sensor_v1:34:14: error: 'lOW' was not declared in this scope

pirState = lOW;

^~~

C:\Users\user\Documents\Arduino\Pir_sensor_v1\Pir_sensor_v1.ino:34:14: note: suggested alternative: 'LOW'

pirState = lOW;

^~~

LOW

C:\Users\user\Documents\Arduino\Pir_sensor_v1\Pir_sensor_v1.ino: At global scope:

Pir_sensor_v1:38:1: error: expected declaration before '}' token

}

^

exit status 1

expected ')' before ';' token

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

This has indeed resolved the initial error. Now you have the bugs in your sketch.

You are experiencing the common situation where there are multiple problems all stacked on top of each other. In this case, fixing the first problem only exposes the second one, but that's still progress! Just keep working your way through them and you'll be sure to achieve success with your goals.

void setup() {
  int ledPin = 13;
int pirPin = 9;
int val = 0;
void setup()
{

that second “void setup ()” should not be there.
Or the first “void setup (){” shouldn’t be there.

Probably the first one should go.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.