Loading
Loading
IoT Lab content is currently available in Arabic only. We're working on an English version.
عرض بالعربية →Get rid of the delay() function and make Arduino do more than one thing at the same time.
Two separate LEDs.
unsigned long lastBlink = 0;
const int ledPin = 13;
int ledState = LOW;
void setup() { pinMode(ledPin, OUTPUT); }
void loop() {
unsigned long currentMillis = millis();
// يومض كل 500 مللي ثانية بدون إيقاف الـ loop
if (currentMillis - lastBlink >= 500) {
lastBlink = currentMillis;
ledState = !ledState;
digitalWrite(ledPin, ledState);
}
// هنا يمكنك قراءة حساسات أخرى براحة
}Using an int data type to store the millis() value. millis() reaches large numbers and will overflow the variable size within just 32 seconds if using int. Must use unsigned long.