用单片机和tlc5615怎样实现呼吸灯操作? 电路图的LED应该如何连?这是我连的 没敢加电阻 一加就有问题。。。我想通过输出电压控制灯的亮暗
哪位大佬能帮忙看看问题在哪?
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
sbit TLC5615_CLK=P2^0;
sbit TLC5615_CS=P2^1;
sbit TLC5615_DI=P2^2;
uint code a[]={450,455,460,465,470,475,480,485,490,495,500,505,510,515,520,525,530,535,540,545,550,555,560,565,570,575,
580,585,590,595,600,605,610,615,620,625,630,635,640,645,650,655,660,665,670,675,680,685,690,695,700,
695,690,685,680,675,670,665,660,655,650,645,640,635,630,625,620,615,610,605,600,595,590,585,580,
575,570,565,560,555,550,545,540,535,530,525,520,515,510,505,500,495,490,485,480,475,470,465,460,455,450};
int main()
{
void TLC5615_DAC(uint dat);
void delayms(uint x);
uint m=0;
while(1)
{
TLC5615_DAC(a[m]);
m++;
if(m>100)
m=0;
}
return 0;
}
void TLC5615_DAC(uint dat)
{
uchar i;
dat<<=6;
TLC5615_CLK=0;
TLC5615_CS=0;
for (i=0;i<12;i++)
{
TLC5615_DI=(bit)(dat&0x8000);
TLC5615_CLK=0;
dat<<=1;
TLC5615_CLK=1;
}
TLC5615_CS=1;
TLC5615_CLK=0;
delayms(200);
}
void delayms(uint x)
{
uchar i;
while(x--);
for(i=0;i<123;i++);
}
|