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

Arduino.TW樂園

Member Area
5線式16*40埠PWM4096階層IC - TLC5940
站長Blog文章單元 - Arduino擴充IO (PWM IC, LED Driver IC, Digital/Analo)
作者是 Administrator   
週二, 17 十一月 2009 00:14

RGB LED

 

單顆五線式ICTLC5940 單顆可以控制16個4096階層,有可繼續串接40顆IC。

http://code.google.com/p/tlc5940arduino/

程式碼 請參閱

 

/*
    A simple 1-d oscilliscope: scan all the channels, setting the PWM output
    value to 4x the analog pin 0 value (0 - 1024 * 4 = 4096).  The value will
    fade to zero as the channels keep scanning.

    See the BasicUse example for hardware setup.

    Alex Leone <acleone ~AT~ gmail.com>, 2009-02-03 */

#include "Tlc5940.h"
#include "tlc_fades.h"

// which analog pin to use
#define ANALOG_PIN      0

// how many millis to strobe over all the LEDs
#define SCOPE_PERIOD    (1000 * NUM_TLCS)
#define LED_PERIOD      SCOPE_PERIOD / (NUM_TLCS * 16)

TLC_CHANNEL_TYPE channel;

void setup()
{
  Tlc.init();
}

void loop()
{
  uint32_t lastMillis = millis();
  tlc_addFade(channel,                      // led channel
              analogRead(ANALOG_PIN) * 4,   // start fade value (0-4095)
              0,                            // end fade value (0-4095)
              lastMillis + 2,               // start millis
              lastMillis + (uint16_t)SCOPE_PERIOD / 4  // end millis
             );
  if (channel++ == NUM_TLCS * 16) {
    channel = 0;
  }
  uint32_t currentMillis;
  do {
    currentMillis = millis();
    tlc_updateFades(currentMillis);
  } while (currentMillis - lastMillis <= LED_PERIOD);
}
 

 

 


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