วันอังคารที่ 14 สิงหาคม พ.ศ. 2561
งานปฏิบัติ 1
//คำสั่งทำให้มอเตอร์หมุนแล้วไฟติด2ดวง
int LED1 = 4;
int LED2 = 5;
int LED3 = 6;
int LED4 = 7;
int LED5 = 8;
int LED6 = 9;
int LED7 = 10;
int LED81 = 11;
int LED9 = 12;
void setup() {
pinMode(LED1,OUTPUT);
pinMode(LED2,OUTPUT);
pinMode(LED3,OUTPUT);
pinMode(LED4,OUTPUT);
pinMode(LED5,OUTPUT);
pinMode(LED6,OUTPUT);
pinMode(LED7,OUTPUT);
pinMode(LED81,OUTPUT);
pinMode(LED9,OUTPUT);
}
void loop() {
digitalWrite(LED1,HIGH);
delay(30);
digitalWrite(LED1,LOW);
delay(30);
if (LED1 == HIGH);
digitalWrite(LED2,HIGH);
delay(30);
digitalWrite(LED2,LOW);
delay(30);
if (LED2 == HIGH);
digitalWrite(LED3,HIGH);
delay(30);
digitalWrite(LED3,LOW);
delay(30);
if (LED3 == HIGH);
digitalWrite(LED4,HIGH);
delay(30);
digitalWrite(LED4,LOW);
delay(30);
if (LED4 == HIGH);
digitalWrite(LED5,HIGH);
delay(30);
digitalWrite(LED5,LOW);
delay(30);
if (LED5 == HIGH);
digitalWrite(LED6,HIGH);
delay(30);
digitalWrite(LED6,LOW);
delay(30);
if (LED6 == HIGH);
digitalWrite(LED7,HIGH);
delay(30);
digitalWrite(LED7,LOW);
delay(30);
if (LED7 == HIGH);
digitalWrite(LED81,HIGH);
delay(30);
digitalWrite(LED81,LOW);
delay(30);
if (LED81 == HIGH);
digitalWrite(LED9,HIGH);
delay(30);
digitalWrite(LED9,LOW);
delay(30);
if (LED4 == HIGH);
digitalWrite(LED1,LOW);
delay(100);
digitalWrite(LED2,LOW);
delay(100);
digitalWrite(LED3,LOW);
delay(100);
digitalWrite(LED4,LOW);
delay(100);
digitalWrite(LED5,LOW);
delay(100);
digitalWrite(LED6,LOW);
delay(100);
digitalWrite(LED7,LOW);
delay(100);
digitalWrite(LED81,LOW);
delay(100);
digitalWrite(LED9,LOW);
delay(100);
if (LED9 == HIGH);
digitalWrite(LED1,HIGH);
delay(100);
digitalWrite(LED2,HIGH);
delay(100);
digitalWrite(LED3,HIGH);
delay(100);
digitalWrite(LED4,HIGH);
delay(100);
digitalWrite(LED5,HIGH);
delay(100);
digitalWrite(LED6,HIGH);
delay(100);
digitalWrite(LED7,HIGH);
delay(100);
digitalWrite(LED81,HIGH);
delay(100);
digitalWrite(LED9,HIGH);
delay(100);
digitalWrite(LED1,LOW);
delay(100);
digitalWrite(LED2,LOW);
delay(100);
digitalWrite(LED3,LOW);
delay(100);
digitalWrite(LED4,LOW);
delay(100);
digitalWrite(LED5,LOW);
delay(100);
digitalWrite(LED6,LOW);
delay(100);
digitalWrite(LED7,LOW);
delay(100);
digitalWrite(LED81,LOW);
delay(100);
digitalWrite(LED9,LOW);
delay(100);
if (LED9 == HIGH);
digitalWrite(LED1,HIGH);
delay(100);
digitalWrite(LED2,HIGH);
delay(100);
digitalWrite(LED3,HIGH);
delay(100);
digitalWrite(LED4,HIGH);
delay(100);
digitalWrite(LED5,HIGH);
delay(100);
digitalWrite(LED6,HIGH);
delay(100);
digitalWrite(LED7,HIGH);
delay(100);
digitalWrite(LED81,HIGH);
delay(100);
digitalWrite(LED9,HIGH);
delay(100);
digitalWrite(LED1,LOW);
delay(100);
digitalWrite(LED2,LOW);
delay(100);
digitalWrite(LED3,LOW);
delay(100);
digitalWrite(LED4,LOW);
delay(100);
digitalWrite(LED5,LOW);
delay(100);
digitalWrite(LED6,LOW);
delay(100);
digitalWrite(LED7,LOW);
delay(100);
digitalWrite(LED81,LOW);
delay(100);
digitalWrite(LED9,LOW);
delay(100);
if (LED9 == HIGH);
digitalWrite(LED1,HIGH);
delay(100);
digitalWrite(LED2,HIGH);
delay(100);
digitalWrite(LED3,HIGH);
delay(100);
digitalWrite(LED4,HIGH);
delay(100);
digitalWrite(LED5,HIGH);
delay(100);
digitalWrite(LED6,HIGH);
delay(100);
digitalWrite(LED7,HIGH);
delay(100);
digitalWrite(LED81,HIGH);
delay(100);
digitalWrite(LED9,HIGH);
delay(100);
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
digitalWrite(LED5,LOW);
digitalWrite(LED6,LOW);
digitalWrite(LED7,LOW);
digitalWrite(LED81,LOW);
digitalWrite(LED9,LOW);
delay(100);
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH);
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7,HIGH);
digitalWrite(LED81,HIGH);
digitalWrite(LED9,HIGH);
delay(100);
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
digitalWrite(LED5,LOW);
digitalWrite(LED6,LOW);
digitalWrite(LED7,LOW);
digitalWrite(LED81,LOW);
digitalWrite(LED9,LOW);
delay(100);
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH);
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7,HIGH);
digitalWrite(LED81,HIGH);
digitalWrite(LED9,HIGH);
delay(100);
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
digitalWrite(LED5,LOW);
digitalWrite(LED6,LOW);
digitalWrite(LED7,LOW);
digitalWrite(LED81,LOW);
digitalWrite(LED9,LOW);
delay(100);
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH);
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7,HIGH);
digitalWrite(LED81,HIGH);
digitalWrite(LED9,HIGH);
delay(100);
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
digitalWrite(LED5,LOW);
digitalWrite(LED6,LOW);
digitalWrite(LED7,LOW);
digitalWrite(LED81,LOW);
digitalWrite(LED9,LOW);
delay(100);
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH);
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7,HIGH);
digitalWrite(LED81,HIGH);
digitalWrite(LED9,HIGH);
delay(100);
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
digitalWrite(LED5,LOW);
digitalWrite(LED6,LOW);
digitalWrite(LED7,LOW);
digitalWrite(LED81,LOW);
digitalWrite(LED9,LOW);
delay(100);
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH);
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7,HIGH);
digitalWrite(LED81,HIGH);
digitalWrite(LED9,HIGH);
delay(100);
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
digitalWrite(LED5,LOW);
digitalWrite(LED6,LOW);
digitalWrite(LED7,LOW);
digitalWrite(LED81,LOW);
digitalWrite(LED9,LOW);
delay(100);
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH);
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7,HIGH);
digitalWrite(LED81,HIGH);
digitalWrite(LED9,HIGH);
delay(100);
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
digitalWrite(LED5,LOW);
digitalWrite(LED6,LOW);
digitalWrite(LED7,LOW);
digitalWrite(LED81,LOW);
digitalWrite(LED9,LOW);
delay(100);
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH);
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7,HIGH);
digitalWrite(LED81,HIGH);
digitalWrite(LED9,HIGH);
delay(100);
}
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น