unsigned char port1 = 0b00000010;
unsigned char port2 = 0b00000100;
unsigned char port3 = 0b00001000;
unsigned char port4 = 0b00010000;
unsigned char port5 = 0b00100000;
unsigned char port6 = 0b01000000;
unsigned char port7 = 0b10000000;
void function1(uint8_t x) {
PORTD = x;
}
void setup() {
DDRD = 0b11111111;
}
void loop() {
// وضع الكود الرئيسي هنا، ليعمل بشكل متكرر:
for (int i = 0; i <= 9; i++) {
function2(i);
delay(1000);
}
for (int i = 9; i >= 0; i--) {
function2(i);
delay(1000);
}
}
void function2(unsigned char i) {
uint8_t x = 0; // متغير لحفظ النمط
switch (i) {
case 0:
x = port1 | port2 | port3 | port4 | port5 | port6; // تفعيل الأجزاء المطلوبة
break;
case 1:
x = port2 | port3;
break;
case 2:
x = port1 | port2 |port4 | port5 | port7;
break;
case 3:
x = port1 | port2 | port3 |port4 | port7;
break;
case 4:
x = port2 | port3 |port6 | port7;
break;
case 5:
x = port1 | port3 | port4 | port6 | port7;
break;
case 6:
x = port1 | port3 | port4 | port5 | port6|port7;
break;
case 7:
x = port1 | port2 | port3;
break;
case 8:
x =port1 | port2 | port3 | port4 | port5 | port6 |port7;
break;
case 9:
x = port1 | port2 | port3 | port4 | port6 |port7;
break;
}
function1(x);
}