求解释一下下面的代码
并没有用过蓝牙模块,买了个hc05蓝牙模块,用杜邦线连到
单片机上,接下来就不知道怎么做了,
手机已经搜到蓝牙,但是并不能匹配成功,来个大神给指点一下。
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
switch(__even_in_range(UCA1IV,4))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
while (!(UCA1IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCA1TXBUF = UCA1RXBUF; // TX -> RXed character
if(UCA1RXBUF=='1')
{
P1OUT ^= BIT1;
Key=1;
}
if(UCA1RXBUF=='2')
{
P1OUT ^= BIT2;
Key=2;
}
if(UCA1RXBUF=='3')
{
P1OUT ^= BIT3;
Key=3;
}
if(UCA1RXBUF=='4')
{
P1OUT ^= BIT4;
Key=4;
}
//Delays();
break; // Vector 4 - TXIFG
default: break;
case 4:break;
}
}
/*
*
*/
#pragma vector=
tiMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void)
{
//timeCounter++;
//if(timeCounter==100)
//{
//P1OUT ^= BIT0;
//Snake_downflag=1;
//timeCounter=0;
//}
randomNumber=++randomNumber%100;
//if(downflag==0)
timeA++;
if(timeA==(11-Speed)*10)
{
timeA=0;
downflag=1;
Snake_downflag=1;
P1OUT ^= BIT0;
}
}
一周热门 更多>