#define LEN 8 //缓冲区长度,建议大于5
unsigned int keyVal = 8;//按键的值,弹起不会变0(1-8)
unsigned int rockerVal = 521;//摇杆的值,停下变0xff 0xff(0-360)
unsigned int seekBarVal = 50;//滑块的值(0-100)
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void Uart_Receive(unsigned char cha)
{
static unsigned char str[8];
static unsigned char sta = 0;
if((sta & 0x80) == 0)
{
if(sta & 0x40)
{
if(cha != 0x0D)
{
sta = 0;
}
else
{
sta |= 0x80;
sta <<= 2;
sta >>= 2;
Rocker_Data_Analyze(str,sta);
sta = 0;
}
}
else
{
if(cha == 0x0A)
{
sta |= 0x40;
}
else
{
str[sta & 0x3F] = cha;
sta++;
if(sta > (LEN - 1))
{
sta = 0;
}
}
}
}
}
/*
//函数:step 功能:控制步进电机方向,步数。
//参数:dir 方向控制, dirPin对应步进电机的DIR引脚,stepperPin 对应步进电机的step引脚, steps 步进的步数
//无返回值
*/
void step(boolean dir, byte dirPin, byte stepperPin, unsigned long int steps,unsigned int TIME)
{
digitalWrite(dirPin,dir);//dir为true 则dirPin引脚输出高电平,dir为false则dirPin引脚输出低电平
//delay(50);
for (unsigned long int i = 0; i < steps; i++) //脉冲信号需<1kHz
{
judge();
digitalWrite(stepperPin, HIGH);//stepperPin引脚输出高电平
delayMicroseconds(TIME);//延时300us