How many errors are present in the code given below if it is made to run on an Arduino Uno? [code] void setup() { Serial.begin();

How many errors are present in the code given below if it is made to run on an Arduino Uno?
Code:
void setup() {
    Serial.begin();
    analogReference(AR_DEFAULT);
}
void loop() {
    //Do nothing.
}
A. 1
B. 2
C. 3
D. 4
 
Answer: B
Explanation: In the code above there are 2 errors in lines 2 and 3. The first one is that the Serial.begin() function is given no baud-rate as input. The second one is that the AR_DEFAULT argument only works for Arduino SAMD Boards like the Arduino Zero and not the Arduino AVR Based Boards like the Arduino Uno on which the above code is to be executed.
 

Tìm kiếm

Back
Top