Skip to content

Instantly share code, notes, and snippets.

@myarduinosale
Created March 6, 2019 14:57
Show Gist options
  • Save myarduinosale/f0bdd0300c7ccdbf1191137d86cebe1b to your computer and use it in GitHub Desktop.
Save myarduinosale/f0bdd0300c7ccdbf1191137d86cebe1b to your computer and use it in GitHub Desktop.
int led1 = 3; // กำหนดขาใช้งาน
int val = 1;
void setup()
{
pinMode(led1, OUTPUT); // กำหนดขาทำหน้าที่ให้ขา 3 เป็น OUTPUT
Serial.begin(9600);
Serial.println("My arduino");
}
void loop()
{
digitalWrite(led1, HIGH); // ไฟ LED 1 ติด
Serial.print(val); // Arduino ส่งค่าในตัว แปล val ให้ arduino
Serial.print("ON "); // Arduino ส่งคำว่า "ON "
Serial.println("LED"); // Arduino ส่งคำว่า "LED"
delay(2000); // ดีเลย์ 2000 มิลลิวินาที
digitalWrite(led1, LOW); // ไฟ LED 1 ดับ
Serial.print("OFF "); // Arduino ส่งคำว่า "OFF "
Serial.println("LED"); // Arduino ส่งคำว่า "LED"
delay(2000); // ดีเลย์ 2000 มิลลิวินาที
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment