ไฟกระพริบ
การต่อแบบไฟกระพริบ |
int L1 = 8;
int L6=5; int L7=6; int L8=7; int L9=8; int L10=9;
void setup() {
pinMode(L1,OUTPUT); pinMode(L2,OUTPUT);
pinMode(L3,OUTPUT); pinMode(L4,OUTPUT);
pinMode(L5,OUTPUT); pinMode(L6,OUTPUT);
pinMode(L7,OUTPUT); pinMode(L8,OUTPUT);
pinMode(L9,OUTPUT); pinMode(L10,OUTPUT);
}
void loop() {
digitalWrite(L1,HIGH); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,HIGH);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,HIGH); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,HIGH);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,HIGH); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,HIGH);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,HIGH); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,HIGH);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,HIGH);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,HIGH); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,HIGH);
delay (500);
}
void setup() {
pinMode(L1, OUTPUT);
}
void loop() {
digitalWrite(L1, HIGH);
delay(500);
digitalWrite(L1, LOW);
delay(500);
}
ไฟวิ่ง
การต่อแบบไฟวิ่ง |
โค้ด (Code Arduino)
int L1=0; int L2=1; int L3=2; int L4=3; int L5=4; int L6=5; int L7=6; int L8=7; int L9=8; int L10=9;
void setup() {
pinMode(L1,OUTPUT); pinMode(L2,OUTPUT);
pinMode(L3,OUTPUT); pinMode(L4,OUTPUT);
pinMode(L5,OUTPUT); pinMode(L6,OUTPUT);
pinMode(L7,OUTPUT); pinMode(L8,OUTPUT);
pinMode(L9,OUTPUT); pinMode(L10,OUTPUT);
}
void loop() {
digitalWrite(L1,HIGH); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,HIGH);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,HIGH); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,HIGH);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,HIGH); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,HIGH);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,HIGH); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,HIGH);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,HIGH);
digitalWrite(L9,LOW); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,HIGH); digitalWrite(L10,LOW);
delay (500);
digitalWrite(L1,LOW); digitalWrite(L2,LOW);
digitalWrite(L3,LOW); digitalWrite(L4,LOW);
digitalWrite(L5,LOW); digitalWrite(L6,LOW);
digitalWrite(L7,LOW); digitalWrite(L8,LOW);
digitalWrite(L9,LOW); digitalWrite(L10,HIGH);
delay (500);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น