2018年8月2日 星期四

專題許願池,請不要吝嗇將你想製作的專題用回覆的方式寫在下方

專題許願池

開這個板是為了幫助一些人,有專題製作需求,但是又不知道要如何實現
如果您有想製作的專題,請您將您的題目回覆在下方,先提出您的需求,進而討論可行性或製做的方向,或是您進行到什麼階段,有遇到什麼樣的問題也可以提出來討論,如果我知道會盡量幫助您順利完成。


  • 不限題目內容,歡迎天馬行空
  • 不限專案大小
  • 不限開發環境(51、STM32、Arduino......小弟都略懂)
  • 不限機構複雜度,機構開發小弟也愛玩,基本的2D3D圖面也都會畫,歡迎討論

原則上歡迎提出您的想法
如果小弟有時間,也許會挑選有趣的題目製做。


如果您有其他專案開發的需求,也請留下您的聯絡方式
我會再與您聯繫,謝謝


以下是目前小弟想做的項目給您參考

藍芽遙控車

其實這個題目的車子我已經做過超過數十台,從手掌大小的車子到一公尺長的工業載運車我都做過,實驗用的輪型機器人平台、娛樂用的改裝RC遙控車10:1、工業用的自動載貨設備都有相關的經驗,不同的需求不同的機構,有不同的樂趣,這次希望做的是32:1的藍芽遙控車,要用來拐我姪子的,希望可以藍芽遙控、4輪驅動,如下圖,因為原先TAMIYA的車型雖然是四驅的,但是並不能左右轉,在機構上又是一大挑戰,希望有時間可以動工。




居家環境監控系統

包含環境各種資訊偵測,溫度、濕度、亮度、控制燈光、設備開關等,配合電腦端介面或是手機端介面判讀或是修改,未來希望這樣的設備可以用在自己家裡,或是其他的商業空間,比方說餐廳的廚房,也許需要多組溫度監測與控制,或是計時器,我們就可以透過小專題的形式來做,然後再將各個單體串接起來,製做一個全面的監控系統。

其實市面上也有類似的產品,但總是沒有那麼容易使用,可碩性不高,最好的就是我們自己做,要怎麼改都隨我的意思。



如果您有其他專案開發的需求,也請留下您的聯絡方式
我會再與您聯繫,謝謝

Android Serial串列通訊,Serial資料傳送


今天要討論的是如何透過Arduino傳送Serial的資料給電腦,本次實驗只是簡單將開發板透過USB跟電腦接即可,未來我們可以透過這個方式讓Arduino將環境中的狀態回傳給電腦,或是傳給其他的設備周邊裝置。有些人會覺得Serial是很古老的通訊方式,不過雖然古老但是很通用,至今就算是最新型的高級電腦,開發初期也都還是用這個方式在將資訊狀態傳給開發人員的。


接線方式

本實驗不需要任何接線,插上USB即可


測試程式

本次是用內建的範例ASCII table範例做修改,透過Serial的程式將數據傳送到串列的監控視窗
值得注意的是,傳送的方式有兩種,一種最後會加上換行符號。

/*
  Serial
*/

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  // prints title with ending line break
  Serial.println("Hello Arduino !! ");
}

void loop() {
  //傳送字串" TEST 1 "
  Serial.print(" TEST 1 ");
  //傳送字串" TEST 2 "最後加上換行符號
  Serial.println(" TEST 2 ");

  while (true) {   continue;   }

}


實際回傳的畫面

回傳"Hello Arduino !! "與


未來應用

此程式通常運用在寫通訊部分程式,熟用後可以將Arduino上判讀到的外部訊息回傳到電腦或其他裝置,日後可以延伸制將數據資料傳送至開發板,設定開發板上的參數


  • 遙控車或其他遙控裝置
  • 無線溫度計或其他數據傳輸
  • 開發環境Debug或資料溝通

Android Serial串列通訊,ASCII Table,產生ASCII對應的十進制十六進制對應的數值


今天要討論的是透過Arduino產生ASCII的對應表,這個在撰寫通訊程式的時候時常需要用到,在接收到一串資料後,透過英文或數字的文字分別對應的數值,再進行判斷或處理接收到的資料。

本次實驗採用Arduino NANO的實驗板,實際上不論哪一個實驗板都可以執行這個程式,並不需要任何的接線,可以簡單的了解ASCII對應的字元實際的數值,也可以透過本程式了解在arduino上傳送資料的一些方法與技巧

本章主要實現如下三點:
  • ASCII轉二進制(Bin)
  • ASCII轉十進制(Dec)
  • ASCII轉十六進制(Hex)



接線方式

本實驗不需要任何接線,插上USB即可


測試程式

本次是用內建的範例ASCII table範例做介紹,透過Serial的程式將數據傳送到串列的監控視窗

/*
  ASCII table

  Prints out byte values in all possible formats:
  - as raw binary values
  - as ASCII-encoded decimal, hex, octal, and binary values

  For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII

  The circuit: No external hardware needed.

  created 2006
  by Nicholas Zambetti <http://www.zambetti.com>
  modified 9 Apr 2012
  by Tom Igoe

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/ASCIITable
*/

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // prints title with ending line break
  Serial.println("ASCII Table ~ Character Map");
}

// first visible ASCIIcharacter '!' is number 33:
int thisByte = 33;
// you can also write ASCII characters in single quotes.
// for example, '!' is the same as 33, so you could also use this:
// int thisByte = '!';

void loop() {
  // prints value unaltered, i.e. the raw binary version of the byte.
  // The Serial Monitor interprets all bytes as ASCII, so 33, the first number,
  // will show up as '!'
  Serial.write(thisByte);

  Serial.print(", dec: ");
  // prints value as string as an ASCII-encoded decimal (base 10).
  // Decimal is the default format for Serial.print() and Serial.println(),
  // so no modifier is needed:
  Serial.print(thisByte);
  // But you can declare the modifier for decimal if you want to.
  // this also works if you uncomment it:

  // Serial.print(thisByte, DEC);


  Serial.print(", hex: ");
  // prints value as string in hexadecimal (base 16):
  Serial.print(thisByte, HEX);

  Serial.print(", oct: ");
  // prints value as string in octal (base 8);
  Serial.print(thisByte, OCT);

  Serial.print(", bin: ");
  // prints value as string in binary (base 2) also prints ending line break:
  Serial.println(thisByte, BIN);

  // if printed last visible character '~' or 126, stop:
  if (thisByte == 126) {    // you could also use if (thisByte == '~') {
    // This loop loops forever and does nothing
    while (true) {
      continue;
    }
  }
  // go on to the next character
  thisByte++;
}


實際回傳的畫面


實際回傳的數值

ASCII Table ~ Character Map
!, dec: 33, hex: 21, oct: 41, bin: 100001
", dec: 34, hex: 22, oct: 42, bin: 100010
#, dec: 35, hex: 23, oct: 43, bin: 100011
$, dec: 36, hex: 24, oct: 44, bin: 100100
%, dec: 37, hex: 25, oct: 45, bin: 100101
&, dec: 38, hex: 26, oct: 46, bin: 100110
', dec: 39, hex: 27, oct: 47, bin: 100111
(, dec: 40, hex: 28, oct: 50, bin: 101000
), dec: 41, hex: 29, oct: 51, bin: 101001
*, dec: 42, hex: 2A, oct: 52, bin: 101010
+, dec: 43, hex: 2B, oct: 53, bin: 101011
,, dec: 44, hex: 2C, oct: 54, bin: 101100
-, dec: 45, hex: 2D, oct: 55, bin: 101101
., dec: 46, hex: 2E, oct: 56, bin: 101110
/, dec: 47, hex: 2F, oct: 57, bin: 101111
0, dec: 48, hex: 30, oct: 60, bin: 110000
1, dec: 49, hex: 31, oct: 61, bin: 110001
2, dec: 50, hex: 32, oct: 62, bin: 110010
3, dec: 51, hex: 33, oct: 63, bin: 110011
4, dec: 52, hex: 34, oct: 64, bin: 110100
5, dec: 53, hex: 35, oct: 65, bin: 110101
6, dec: 54, hex: 36, oct: 66, bin: 110110
7, dec: 55, hex: 37, oct: 67, bin: 110111
8, dec: 56, hex: 38, oct: 70, bin: 111000
9, dec: 57, hex: 39, oct: 71, bin: 111001
:, dec: 58, hex: 3A, oct: 72, bin: 111010
;, dec: 59, hex: 3B, oct: 73, bin: 111011
<, dec: 60, hex: 3C, oct: 74, bin: 111100
=, dec: 61, hex: 3D, oct: 75, bin: 111101
>, dec: 62, hex: 3E, oct: 76, bin: 111110
?, dec: 63, hex: 3F, oct: 77, bin: 111111
@, dec: 64, hex: 40, oct: 100, bin: 1000000
A, dec: 65, hex: 41, oct: 101, bin: 1000001
B, dec: 66, hex: 42, oct: 102, bin: 1000010
C, dec: 67, hex: 43, oct: 103, bin: 1000011
D, dec: 68, hex: 44, oct: 104, bin: 1000100
E, dec: 69, hex: 45, oct: 105, bin: 1000101
F, dec: 70, hex: 46, oct: 106, bin: 1000110
G, dec: 71, hex: 47, oct: 107, bin: 1000111
H, dec: 72, hex: 48, oct: 110, bin: 1001000
I, dec: 73, hex: 49, oct: 111, bin: 1001001
J, dec: 74, hex: 4A, oct: 112, bin: 1001010
K, dec: 75, hex: 4B, oct: 113, bin: 1001011
L, dec: 76, hex: 4C, oct: 114, bin: 1001100
M, dec: 77, hex: 4D, oct: 115, bin: 1001101
N, dec: 78, hex: 4E, oct: 116, bin: 1001110
O, dec: 79, hex: 4F, oct: 117, bin: 1001111
P, dec: 80, hex: 50, oct: 120, bin: 1010000
Q, dec: 81, hex: 51, oct: 121, bin: 1010001
R, dec: 82, hex: 52, oct: 122, bin: 1010010
S, dec: 83, hex: 53, oct: 123, bin: 1010011
T, dec: 84, hex: 54, oct: 124, bin: 1010100
U, dec: 85, hex: 55, oct: 125, bin: 1010101
V, dec: 86, hex: 56, oct: 126, bin: 1010110
W, dec: 87, hex: 57, oct: 127, bin: 1010111
X, dec: 88, hex: 58, oct: 130, bin: 1011000
Y, dec: 89, hex: 59, oct: 131, bin: 1011001
Z, dec: 90, hex: 5A, oct: 132, bin: 1011010
[, dec: 91, hex: 5B, oct: 133, bin: 1011011
\, dec: 92, hex: 5C, oct: 134, bin: 1011100
], dec: 93, hex: 5D, oct: 135, bin: 1011101
^, dec: 94, hex: 5E, oct: 136, bin: 1011110
_, dec: 95, hex: 5F, oct: 137, bin: 1011111
`, dec: 96, hex: 60, oct: 140, bin: 1100000
a, dec: 97, hex: 61, oct: 141, bin: 1100001
b, dec: 98, hex: 62, oct: 142, bin: 1100010
c, dec: 99, hex: 63, oct: 143, bin: 1100011
d, dec: 100, hex: 64, oct: 144, bin: 1100100
e, dec: 101, hex: 65, oct: 145, bin: 1100101
f, dec: 102, hex: 66, oct: 146, bin: 1100110
g, dec: 103, hex: 67, oct: 147, bin: 1100111
h, dec: 104, hex: 68, oct: 150, bin: 1101000
i, dec: 105, hex: 69, oct: 151, bin: 1101001
j, dec: 106, hex: 6A, oct: 152, bin: 1101010
k, dec: 107, hex: 6B, oct: 153, bin: 1101011
l, dec: 108, hex: 6C, oct: 154, bin: 1101100
m, dec: 109, hex: 6D, oct: 155, bin: 1101101
n, dec: 110, hex: 6E, oct: 156, bin: 1101110
o, dec: 111, hex: 6F, oct: 157, bin: 1101111
p, dec: 112, hex: 70, oct: 160, bin: 1110000
q, dec: 113, hex: 71, oct: 161, bin: 1110001
r, dec: 114, hex: 72, oct: 162, bin: 1110010
s, dec: 115, hex: 73, oct: 163, bin: 1110011
t, dec: 116, hex: 74, oct: 164, bin: 1110100
u, dec: 117, hex: 75, oct: 165, bin: 1110101
v, dec: 118, hex: 76, oct: 166, bin: 1110110
w, dec: 119, hex: 77, oct: 167, bin: 1110111
x, dec: 120, hex: 78, oct: 170, bin: 1111000
y, dec: 121, hex: 79, oct: 171, bin: 1111001
z, dec: 122, hex: 7A, oct: 172, bin: 1111010
{, dec: 123, hex: 7B, oct: 173, bin: 1111011
|, dec: 124, hex: 7C, oct: 174, bin: 1111100
}, dec: 125, hex: 7D, oct: 175, bin: 1111101
~, dec: 126, hex: 7E, oct: 176, bin: 1111110


未來應用

此部分程式通常運用在寫通訊協定,再已知或未知的通訊協定做了解或判讀
是學習單晶片或是MCU必須要了解的基本常識


2018年8月1日 星期三

Android 基本應用,I/O 輸入input ,按下按鈕令LED亮

本章節要提到在玩Arduino最初期應該要做的第二個實驗,就是最基本的功能,IO控制中的INPUT,MCU的出PIN大多都可以透過程式設定為"輸入input"或"輸出output",輸入可以讀取外部訊號,而輸出,顧名思義就是可以控制外部。
透過判讀該腳位外部狀態為"HI"或是"LOW",執行對應程式或是功能,在原先內部的範例程式中,需要額外加上一個PULL UP電阻,但實際上可以透過修改程式節省這顆電阻,讓IC在內部PULL UP,這樣的做法可以簡單化電路,減少零件花費,但不是所有的IC都有支援。





















接線方式

今天採用的是Arduino NANO 板上的LED,再加上一根單心線,如果您希望電路整潔,可以換成Button的按鈕,由於我修改了程式,所以也不需要額外的put up電阻10K,但不是在每一種IC上都可以這麼用。


測試程式
本次是用內建的範例Button範例做最小幅度的修改,因為這樣可以更簡單使用,不用外部再加PULL UP電阻
/*
  Button

  Turns on and off a light emitting diode(LED) connected to digital pin 13,
  when pressing a pushbutton attached to pin 2.

  The circuit:
  - LED attached from pin 13 to ground
  - pushbutton attached to pin 2 from +5V
  - 10K resistor attached to pin 2 from ground

  - Note: on most Arduinos there is already an LED on the board
    attached to pin 13.

  created 2005
  by DojoDave <http://www.0j0.org>
  modified 30 Aug 2011
  by Tom Igoe

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/Button
*/

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  //pinMode(buttonPin, INPUT); 
  pinMode(buttonPin, INPUT_PULLUP); //enable pull-up resistor
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == LOW) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  } else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}



實際測試影片
實驗的過程為求簡單所以用單心線替代BUTTON,麵包板上接觸的點是GND







    Android 基本應用,I/O output ,LED閃爍

    本章節要提到在玩Arduino最初期應該要做的第一個實驗,就是最基本的功能,IO控制中的OUTPUT,MCU的出PIN大多都可以透過程式設定為"輸入input"或"輸出output",輸入可以讀取外部訊號,而輸出,顧名思義就是可以控制外部,可以設定該PIN腳的狀態,是屬於HI或LOW,本次的實驗,該PIN腳在Arduino NANO的板子上已經接往一顆LED,控制這跟接腳輸出狀態為"HI"或"LOW"可以讓LED亮滅,透過時間的延遲,看起來就是LED在閃爍,如最下面的影片。





















    接線方式

    今天採用的是Arduino NANO 板上的LED,故不需要任何接線,如果您的實驗板沒有LED,可以將訊號腳接至電表,透過電表的電壓,確認輸出是否為HI_LOW_HI_LOW不斷循環

    測試程式
    本次是用內建的Blink範例做最小幅度的修改,因為這樣可能更容易理解一些

    /*
      Blink

      Turns an LED on for one second, then off for one second, repeatedly.

      Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
      it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
      the correct LED pin independent of which board is used.
      If you want to know what pin the on-board LED is connected to on your Arduino
      model, check the Technical Specs of your board at:
      https://www.arduino.cc/en/Main/Products

      modified 8 May 2014
      by Scott Fitzgerald
      modified 2 Sep 2016
      by Arturo Guadalupi
      modified 8 Sep 2016
      by Colby Newman

      This example code is in the public domain.

      http://www.arduino.cc/en/Tutorial/Blink
    */
    #define LED_PIN       13   

    // the setup function runs once when you press reset or power the board
    void setup() {
      // initialize digital pin LED_BUILTIN as an output.
      pinMode(LED_PIN, OUTPUT);
    }

    // the loop function runs over and over again forever
    void loop() {
      digitalWrite(LED_PIN, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(500);                       // wait for a second
      digitalWrite(LED_PIN, LOW);    // turn the LED off by making the voltage LOW
      delay(500);                       // wait for a second
    }




    實際測試影片









    Arduino RGB 全彩LED WS2812 5050,跑馬燈

    本章要跟大家介紹WS2812這顆RGB LED來製作最簡易的跑馬燈,其實WS2812 RGB LED製作跑馬燈效果相當好,控制電路又簡單,只需要運用到一個數位腳就可以實現控制一整排LED,今天展示的是最簡單的跑馬燈形式



    實際實驗環境



    參考資料
    函式庫網址如下

    請將網址資料打包放至如下資料夾
    "C:\Users\___XXXX___\Documents\Arduino\libraries"

    接線方式

    今天採用的是Arduino NANO + WS2812 RGB LED燈條
    燈條上的DOUT是用來串接後面的燈條用的
    ******************接線方式******************
    NANO                   WS2812燈條

    +5V------------------VCC
    D6------------------DIN
    GND------------------GND
    ********************************************

    範例程式

    如果想要更多的顏色變化,可以自行修改
    由於我實驗的LED燈條有兩顆燒壞了,所以有修改過LED的總數

    // NeoPixel Ring simple sketch (c) 2013 Shae Erisson
    // released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library

    #include <Adafruit_NeoPixel.h>
    #ifdef __AVR__
      #include <avr/power.h>
    #endif

    // Which pin on the Arduino is connected to the NeoPixels?
    // On a Trinket or Gemma we suggest changing this to 1
    #define PIN            6

    // How many NeoPixels are attached to the Arduino?
    #define NUMPIXELS      6

    // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
    // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
    // example for more information on possible values.
    Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

    int delayval = 1000; // delay for half a second

    void setup() {
      // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
    #if defined (__AVR_ATtiny85__)
      if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
    #endif
      // End of trinket special code

      pixels.begin(); // This initializes the NeoPixel library.
    }

    void loop() {

    mode_1();
    mode_2();
    mode_3();

    mode_4();



    }

    void mode_1(){
      int mode_i=0;
      
      for(mode_i=0;mode_i<NUMPIXELS;mode_i++){
        pixels.setPixelColor(mode_i, pixels.Color(20,0,0)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds).
      }
      for(mode_i=0;mode_i<NUMPIXELS;mode_i++){
        pixels.setPixelColor(mode_i, pixels.Color(0,0,0)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds).
      }
        for(mode_i=0;mode_i<NUMPIXELS;mode_i++){
        pixels.setPixelColor(mode_i, pixels.Color(0,20,0)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds).
      }
      for(mode_i=0;mode_i<NUMPIXELS;mode_i++){
        pixels.setPixelColor(mode_i, pixels.Color(0,0,0)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds).
      }
        for(mode_i=0;mode_i<NUMPIXELS;mode_i++){
        pixels.setPixelColor(mode_i, pixels.Color(0,0,20)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds).
      }
      for(mode_i=0;mode_i<NUMPIXELS;mode_i++){
        pixels.setPixelColor(mode_i, pixels.Color(0,0,0)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds).
      }

    }

    void mode_2(){
      int mode_i=0;
      
      for(mode_i=0;mode_i<NUMPIXELS;mode_i++){
        pixels.setPixelColor(mode_i, pixels.Color(20,0,0)); // Moderately bright green color.
        //pixels.setPixelColor((mode_i+NUMPIXELS-1)%NUMPIXELS, pixels.Color(0,0,0)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds).    
        pixels.setPixelColor(mode_i, pixels.Color(0,0,0)); // Moderately bright green color.
      }
      for(mode_i=0;mode_i<NUMPIXELS;mode_i++){
        pixels.setPixelColor(mode_i, pixels.Color(0,20,0)); // Moderately bright green color.
        //pixels.setPixelColor((mode_i+NUMPIXELS-1)%NUMPIXELS, pixels.Color(0,0,0)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds).    
        pixels.setPixelColor(mode_i, pixels.Color(0,0,0)); // Moderately bright green color.
      }
      for(mode_i=0;mode_i<NUMPIXELS;mode_i++){
        pixels.setPixelColor(mode_i, pixels.Color(0,0,20)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds).    
        pixels.setPixelColor(mode_i, pixels.Color(0,0,0)); // Moderately bright green color.
      }
      
    }
    void mode_3(){
      int mode_i=0;
      
      for(mode_i=0;mode_i<NUMPIXELS;mode_i++){
        pixels.setPixelColor(mode_i, pixels.Color(20,0,0)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds). 
        pixels.setPixelColor(mode_i, pixels.Color(0,0,0)); // Moderately bright green color.  
      }
        for(mode_i=NUMPIXELS-1;mode_i>0;mode_i--){
        pixels.setPixelColor(mode_i, pixels.Color(20,0,0)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds). 
        pixels.setPixelColor(mode_i, pixels.Color(0,0,0)); // Moderately bright green color.  
      }

      for(mode_i=0;mode_i<NUMPIXELS;mode_i++){
        pixels.setPixelColor(mode_i, pixels.Color(0,20,0)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds). 
        pixels.setPixelColor(mode_i, pixels.Color(0,0,0)); // Moderately bright green color.  
      }
        for(mode_i=NUMPIXELS-1;mode_i>0;mode_i--){
        pixels.setPixelColor(mode_i, pixels.Color(0,20,0)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds). 
        pixels.setPixelColor(mode_i, pixels.Color(0,0,0)); // Moderately bright green color.  
      }
      
      for(mode_i=0;mode_i<NUMPIXELS;mode_i++){
        pixels.setPixelColor(mode_i, pixels.Color(0,0,20)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds). 
        pixels.setPixelColor(mode_i, pixels.Color(0,0,0)); // Moderately bright green color.  
      }
        for(mode_i=NUMPIXELS-1;mode_i>0;mode_i--){
        pixels.setPixelColor(mode_i, pixels.Color(0,20,0)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(200); // Delay for a period of time (in milliseconds). 
        pixels.setPixelColor(mode_i, pixels.Color(0,0,0)); // Moderately bright green color.  
      }
      
    }

    void mode_4(){
      int mode_i=0,LED_R=0,LED_G=0,LED_B=0;
      
        for(mode_i=0;mode_i<50;mode_i++){
        pixels.setPixelColor(0, pixels.Color(mode_i,0,0)); // Moderately bright green color.    
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(40); // Delay for a period of time (in milliseconds). 
        }
        for(mode_i=50;mode_i>0;mode_i--){
        pixels.setPixelColor(0, pixels.Color(mode_i,0,0)); // Moderately bright green color.    
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(40); // Delay for a period of time (in milliseconds). 
        }
        
        for(mode_i=0;mode_i<50;mode_i++){
        pixels.setPixelColor(0, pixels.Color(0,mode_i,0)); // Moderately bright green color.    
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(40); // Delay for a period of time (in milliseconds). 
        }
        for(mode_i=50;mode_i>0;mode_i--){
        pixels.setPixelColor(0, pixels.Color(0,mode_i,0)); // Moderately bright green color.    
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(40); // Delay for a period of time (in milliseconds). 
        }
        
        for(mode_i=0;mode_i<50;mode_i++){
        pixels.setPixelColor(0, pixels.Color(0,0,mode_i)); // Moderately bright green color.    
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(40); // Delay for a period of time (in milliseconds). 
        }
        for(mode_i=50;mode_i>0;mode_i--){
        pixels.setPixelColor(0, pixels.Color(0,0,mode_i)); // Moderately bright green color.    
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(40); // Delay for a period of time (in milliseconds). 
        }

    }

    實際測試影片




    未來可行的應用

    • 居家的氣氛燈設計
    • 汽車、機車的可動車尾燈
    • 環境中各種可以透過LED變化的應用
    • 生活裝置藝術






    專題許願池,請不要吝嗇將你想製作的專題用回覆的方式寫在下方

    專題許願池 開這個板是為了幫助一些人,有專題製作需求,但是又不知道要如何實現 如果您有想製作的專題,請您將您的題目回覆在下方,先提出您的需求,進而討論可行性或製做的方向,或是您進行到什麼階段,有遇到什麼樣的問題也可以提出來討論,如果我知道會盡量幫助您順利完成。 不限...