Download presentation
Presentation is loading. Please wait.
1
RGB LED 燈條實驗
3
材料 Arduino Uno RGB LED 燈條 杜邦線
4
程式碼 #define REDPIN 5 #define GREENPIN 6 #define BLUEPIN 3
#define FADESPEED // make this higher to slow down void setup() { pinMode(REDPIN, OUTPUT); pinMode(GREENPIN, OUTPUT); pinMode(BLUEPIN, OUTPUT); } void loop() { int r, g, b;
5
程式碼 // fade from blue to violet // fade from green to teal
for (r = 0; r < 256; r++) { analogWrite(REDPIN, r); delay(FADESPEED); } // fade from violet to red for (b = 255; b > 0; b--) { analogWrite(BLUEPIN, b); // fade from red to yellow for (g = 0; g < 256; g++) { analogWrite(GREENPIN, g); // fade from yellow to green for (r = 255; r > 0; r--) { // fade from green to teal for (b = 0; b < 256; b++) { analogWrite(BLUEPIN, b); delay(FADESPEED); } // fade from teal to blue for (g = 255; g > 0; g--) { analogWrite(GREENPIN, g);
6
實驗結果 控制燈條不同的顏色變化
7
資料來源 http://www.olites.com/admin/upfile/proimg/2012128034595095.jpg
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.