const int redLEDPin = 9; // دبوس LED الأحمر
const int greenLEDPin = 10; // دبوس LED الأخضر
unsigned long previousRedMillis = 0; // الوقت الماضي لوميض LED الأحمر
unsigned long previousGreenMillis = 0; // الوقت الماضي لوميض LED الأخضر
const long redBlinkInterval = 1000; // فترة وميض LED الأحمر (1 ثانية)
const long greenBlinkInterval = 200; // فترة وميض LED الأخضر (200 مللي ثانية)
bool redLEDState = LOW; // الحالة الحالية لـ LED الأحمر
bool greenLEDState = LOW; // الحالة الحالية لـ LED الأخضر
void setup() {
pinMode(redLEDPin, OUTPUT);
pinMode(greenLEDPin, OUTPUT);
}
void loop() {
unsigned long currentMillis = millis();
// التحكم في وميض LED الأحمر
if (currentMillis - previousRedMillis >= redBlinkInterval) {
previousRedMillis = currentMillis; // تحديث الوقت الماضي
redLEDState = !redLEDState; // عكس الحالة
digitalWrite(redLEDPin, redLEDState); // تغيير حالة LED الأحمر
}
// التحكم في وميض LED الأخضر
if (currentMillis - previousGreenMillis >= greenBlinkInterval) {
previousGreenMillis = currentMillis; // تحديث الوقت الماضي
greenLEDState = !greenLEDState; // عكس الحالة
digitalWrite(greenLEDPin, greenLEDState); // تغيير حالة LED الأخضر
}
}