int led1 = 2; // กำหนดขาใช้งาน
int led2 = 3;
int led3 = 4;
int led4 = 5;
void setup()
{
pinMode(led1, OUTPUT); // กำหนดขาทำหน้าที่ OUTPUT
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
}
void loop()
{
digitalWrite(led1,HIGH); // ไฟ LED 1 ติด 500 ms
delay(500);
digitalWrite(led1,LOW); // ไฟ LED 1 ดับ500 ms
delay(500);
digitalWrite(led2,HIGH);
delay(500);
digitalWrite(led2,LOW);
delay(500);
digitalWrite(led3,HIGH);
delay(500);
digitalWrite(led3,LOW);
delay(500);
digitalWrite(led4,HIGH);
delay(500);
digitalWrite(led4,LOW);
delay(500);
}
อ้างอิง http://www.myarduino.net/article/6/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%80%E0%B8%82%E0%B8%B5%E0%B8%A2%E0%B8%99%E0%B9%82%E0%B8%9B%E0%B8%A3%E0%B9%81%E0%B8%81%E0%B8%A3%E0%B8%A1%E0%B9%80%E0%B8%9A%E0%B8%B7%E0%B9%89%E0%B8%AD%E0%B8%87%E0%B8%95%E0%B9%89%E0%B8%99%E0%B8%81%E0%B8%B1%E0%B8%9A-arduino-c-%E0%B9%84%E0%B8%9F%E0%B8%A7%E0%B8%B4%E0%B9%88%E0%B8%87
ไม่มีความคิดเห็น:
แสดงความคิดเห็น