• Increase font size
  • Default font size
  • Decrease font size
  • default color
  • cyan color
  • red color

Arduino.TW樂園

Member Area
TLC5940 實作
站長Blog文章單元 - Arduino擴充IO (PWM IC, LED Driver IC, Digital/Analo)
作者是 ken   
週日, 30 五月 2010 00:06

tlc5940的應用:

1. 電路 http://code.google.com/p/tlc5940arduino/

 

2. 下載Tlc5940函式庫

3. 解開zip檔案之後,將裡面的Tlc5940資料夾放到arduino資料夾裡面的libraries裡面

(MAC的要放在/Applications/Arduino0018.app/Contents/Resources/Java/libraries/底下)

4. 然後開啟Tlc5940裡面的example資料夾的Fades範例檔案

 

 

#include "Tlc5940.h"

#include "tlc_fades.h"

 

TLC_CHANNEL_TYPE channel;

 

void setup()

{

  Tlc.init();

}

 

void loop()

{

  if (tlc_fadeBufferSize < TLC_FADE_BUFFER_LENGTH - 2) {

    if (!tlc_isFading(channel)) {

      uint16_t duration = analogRead(0) * 2;

      int maxValue = analogRead(0) * 2;

      uint32_t startMillis = millis() + 50;

      uint32_t endMillis = startMillis + duration;

      tlc_addFade(channel, 0, maxValue, startMillis, endMillis);

      tlc_addFade(channel, maxValue, 0, endMillis, endMillis + duration);

    }

    if (channel++ == NUM_TLCS * 16) {

      channel = 0;

    }

  }

  tlc_updateFades();

}

 

 5. 上傳檔案之後就會看見led燈在來回亮滅


blog comments powered by Disqus
最近更新在 週四, 03 六月 2010 13:49