聚豐項(xiàng)目 > 模擬五線譜燈帶
技術(shù)要點(diǎn): 1,利用AB32VG1集成的藍(lán)牙模塊,連接手機(jī),在線獲取mp3音樂數(shù)據(jù); 2,利用開發(fā)板上功放模塊,進(jìn)行音樂播放; 3,將MP3數(shù)據(jù)轉(zhuǎn)換位五線譜內(nèi)音標(biāo)數(shù)據(jù),控制ws2812燈帶同步顯示五線譜音標(biāo)位置; 最終應(yīng)用:幫助音樂初學(xué)者播放音樂同時(shí),跟著五線譜學(xué)習(xí)各類樂器;
abcdelf
分享abcdelf
團(tuán)隊(duì)成員
陳 軟件工程師
RGB燈帶:ws2812
開發(fā)板:中科藍(lán)訊AB32VG1
uint8_t music_map2[]={0,100, 103,105,108,108,105, 3,103,105,3,99 ,3,103,105,3,99, 3,3,3,100,103,
5,5,3,99,0,103,100,3,100,103, 1,101,103,1,99,100,103,101,100,3,0,3,105,108,3,99};
uint8_t music_map[]={140,120, 110,130,161,103, 143,120,130,100,130,120 ,110,120,140,120,110,130 ,161,103,103,100,
143,120,130,100,130,120,110,120, 143,120,130,120,130,120,110,130, 161,120,100,130,130,120,110,130,
140,120,122,110,130,120,110,122, 20,120,122,120,110,130,103, 140,122,120,110,122,130,122,110};
void RGBLampContr(uint8_t s);
uint32_t GRB[33]={0};
int main(void)
{
uint8_t Count=0;
Delay_Init();
WS2812_Init();
wsData_Lo;
delay_ms(500);
while(1)
{
RGBLampContr(music_map[Count]);
Count++;
if(Count>sizeof(music_map))Count=0;
}
while(1)
{
RGBLampContr(Count);
delay_ms(300);
Count++;
if(Count>16)Count=0;
}
}
void RGBLampContr2(uint8_t s)
{
// switch (s)
// {
// case 0:
// GRB[0]=0;
// GRB[1]=0;
// GRB[2]=0;
// GRB[3]=0;
// break;
// case 1:
// GRB[0]=0xAA0000; //AA?é±? £?FF??ó|??é?áá?è×?′ó
// GRB[1]=0xAA0000;
// GRB[2]=0xAA0000;
// GRB[3]=0xAA0000;
// break;
// case 2:
// GRB[0]=0xAA00;
// GRB[1]=0xAA00;
// GRB[2]=0xAA00;
// GRB[3]=0xAA00;
// break;
// case 3:
// GRB[0]=0xAA;
// GRB[1]=0xAA;
// GRB[2]=0xAA;
// GRB[3]=0xAA;
// break;
// case 4:
// GRB[0]=0x00AAAA;
// GRB[1]=0x00AAAA;
// GRB[2]=0x00AAAA;
// GRB[3]=0x00AAAA;
// break;
// default:break;
// }
// liu shui deng
GRB[(s+15)%16]=0;
GRB[s]=0x00AAAA;
WS2812_SendData(GRB,16);
wsData_Lo;
}
#define PING_TOTAL 8
#define EACH_XIAN_TOTAL (PING_TOTAL+2)
void RGBLampContr(uint8_t s)
{
// xi xian pu
uint16_t speed=6000/(7*((s/100) +1)); //70hz
uint8_t xian_num=(s%100)/10;
uint8_t ping_num=(s%10);
uint8_t led_num=0;
uint32_t led_color= 0x00AAAA;
if(xian_num<4)
{
led_num=(xian_num*EACH_XIAN_TOTAL )+ping_num;
GRB[led_num]=led_color;
WS2812_SendData(GRB,32);
wsData_Lo;
delay_ms(speed);
GRB[led_num]=0;
}
if(xian_num==4) //3zhi
{
led_num=(xian_num*EACH_XIAN_TOTAL )+ping_num;
GRB[led_num]=led_color;
WS2812_SendData(GRB,32);
wsData_Lo;
delay_ms(speed);
GRB[led_num]=0;
}
if(xian_num>4&&xian_num<9) //4zhi
{
led_num=(xian_num*EACH_XIAN_TOTAL )+ping_num;
GRB[led_num]=led_color;
WS2812_SendData(GRB,32);
wsData_Lo;
delay_ms(speed);
GRB[led_num]=0;
}
if(xian_num==9)
{
led_num=6;
GRB[led_num]=0xAA;
GRB[led_num+EACH_XIAN_TOTAL]=0xAA;
GRB[led_num+EACH_XIAN_TOTAL]=0xAA;
GRB[led_num+EACH_XIAN_TOTAL]=0xAA;
WS2812_SendData(GRB,32);
wsData_Lo;
delay_ms(speed);
GRB[led_num]=0;
GRB[led_num+EACH_XIAN_TOTAL]=0;
GRB[led_num+EACH_XIAN_TOTAL]=0;
GRB[led_num+EACH_XIAN_TOTAL]=0;
}
}
燈帶部分實(shí)現(xiàn)了控制