void setup() {
// Initialize serial communication
Serial.begin(9600);
Serial.println("Fetching data...");
// Fetch data and handle it
fetchData(handleData1);
}
void loop() {
// Empty loop since we are simulating a one-time fetch
}
void fetchData(void (*callback)()) {
delay(5000); // Simulate a 2-second delay
callback(); // Call the callback function
}
void handleData1() {
Serial.println("Handling1");
}
void handleData2() {
Serial.println("Handling2");
}