Answer the question
In order to leave comments, you need to log in
Arduino. Flashing LED from setup?
Toaster gurus help me out, I can’t deal with flashing in arduino. As I know setup - it is initialized only 1 time, and loop - has a cycle.
Here is a simple example of flashing an LED
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
if (!SD.begin(4)) { func(); }
//и где-то вынесенное описание
void func();
Answer the question
In order to leave comments, you need to log in
I warn you right away that this is not the most elegant solution, but it seems the most banal.
Throw the function of blinking the LED into an endless loop with one or another exit condition. As far as I understand, in your case, the condition will be the presence of an SD card.
Example:
void loop() {
while (!SD.begin(4)) {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question