What is the objective of the code given below if it is executed on the Arduino Uno? [code] #include<EEPROM.h> int pin=13; void setup()

Linh Chi

New member
What is the objective of the code given below if it is executed on the Arduino Uno?
Code:
#include<EEPROM.h>
int pin=13;
void setup() {
    pinMode(pin,OUTPUT);
    Serial.begin(9600);
}
void loop() {
    for(int i=0;i<EEPROM.length();i++) {
        EEPROM.write(i, 1);
    }
    digitalWrite(pin,HIGH);
    exit(0);
}
A. Fill EEPROM with 1’s
B. Fill EEPROM with 0’s
C. Clear EEPROM
D. Export EEPROM data
 
Answer: A
Explanation: The EEPROM.write() function is used to write data to the EEPROM directly. This function takes in 2 argurments; the address to which the data is to be written, and the data which is to be written to the EEPROM in the specified address. The program fills the EEPROM with 1’s and then turns on the onboard LED of the Arduino Uno.
 

Tìm kiếm

Back
Top