Created
June 26, 2024 19:21
-
-
Save maxpromer/c23820a2e8455c0bd9445e3d66e877ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Adafruit_NeoPixel.h> | |
#define PIN 6 // กำหนดพินที่เชื่อมต่อกับ WS2812 | |
#define NUMPIXELS 16 // กำหนดจำนวน LED ที่ใช้ | |
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); | |
void setup() { | |
pixels.begin(); // เริ่มต้นการทำงานของไลบรารี | |
} | |
void loop() { | |
for(int i=0; i<NUMPIXELS; i++) { | |
pixels.setPixelColor(i, pixels.Color(255, 0, 0)); // ตั้งค่า LED ให้เป็นสีแดง | |
pixels.show(); // แสดงผล | |
delay(50); // หน่วงเวลา | |
} | |
delay(500); | |
for(int i=0; i<NUMPIXELS; i++) { | |
pixels.setPixelColor(i, pixels.Color(0, 255, 0)); // ตั้งค่า LED ให้เป็นสีเขียว | |
pixels.show(); | |
delay(50); | |
} | |
delay(500); | |
for(int i=0; i<NUMPIXELS; i++) { | |
pixels.setPixelColor(i, pixels.Color(0, 0, 255)); // ตั้งค่า LED ให้เป็นสีน้ำเงิน | |
pixels.show(); | |
delay(50); | |
} | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment