#define LED_PIN (LED_BUILTIN) // กำหนด LED_PIN ให้เป็นขา LED เริ่มต้นของบอร์ด (เช่น LED_BUILTIN)
// Define LED_PIN as the default LED pin on the board (e.g., LED_BUILTIN).
#define DELAY_MS (500) // กำหนด DELAY_MS ให้เป็นค่าหน่วงเวลา 500 มิลลิวินาที
// Define DELAY_MS as the delay value of 500 milliseconds.
void setup()
{
// ตั้งค่า LED_PIN เป็น output เพื่อให้สามารถควบคุมสถานะของ LED ได้
// Set the LED pin direction to output to control the LED state.
pinMode( LED_PIN, OUTPUT );
// ตั้งค่า LED_PIN เป็น LOW (ปิด LED) เริ่มต้น
// Set the LED pin to LOW (turn the LED off initially).
digitalWrite( LED_PIN, LOW );
}
void loop()
{
// เรียกใช้ฟังก์ชัน led_blink3 โดยส่ง LED_PIN ไปเป็นพารามิเตอร์
// Call the led_blink3 function with LED_PIN as the parameter.
led_blink3( LED_PIN );
}
void led_blink3( int pin )
{
// สลับสถานะของ LED โดยการอ่านสถานะปัจจุบันแล้วสลับ (จาก LOW เป็น HIGH หรือจาก HIGH เป็น LOW)
// Toggle the LED state by reading its current state and inverting it (from LOW to HIGH or HIGH to LOW).
digitalWrite( pin, !digitalRead(pin) );
// หน่วงเวลาประมาณ 500 มิลลิวินาที ตามที่กำหนดใน DELAY_MS
// Delay for 500 milliseconds as defined by DELAY_MS.
delay( DELAY_MS );
}