程序看不出问题,但进不去循环,求指点。
这是用xbee控制舵机的程序,楼主看了很久觉得没有问题,但始终执行不了,进不去循环,求指点。#include <Arduino.h>
#include <OpenContinMotor.h>
#include <string.h>
#include"OpenXBee.h"
#define servoleft 6
#define servoright 7
int val=100;
unsigned long pulse1;
unsigned long pulse2;
int main(void)
{
Serial.begin(9600);
ContinMotor::InitContinMotorPin(servoleft);
ContinMotor::InitContinMotorPin(servoright);
while(1)
{
if(Serial.available()>0)
{
val=Serial.read();
Serial.flush();
}
switch(val)
{
case 100:
{
pulse1=1300;
pulse2=1700;
/*ContinMotor::PulseOut(servoleft,1300);
ContinMotor::PulseOut(servoright,1700);
Serial.print(222);
delay(20);*/
break;
}
case 200:
{
pulse1=1700;
pulse2=1300;
/*ContinMotor::PulseOut(servoleft,1700);
ContinMotor::PulseOut(servoright,1700);
delay(20);*/ break;
}
case 300:
{
pulse1=1300;
pulse2=1300;
/*ContinMotor::PulseOut(servoleft,1300);
ContinMotor::PulseOut(servoright,1300);
delay(20);*/ break;
}
case 400:
{
pulse1=1700;
pulse2=1700;
/*ContinMotor::PulseOut(servoleft,1700);
ContinMotor::PulseOut(servoright,1300);
delay(20);*/ break;
}
}
ContinMotor::PulseOut(servoleft,pulse1);
ContinMotor::PulseOut(servoright,pulse2);
delay(20);
return(0);
}
} ContinMotor:ulseOut(servoleft,pulse1);
ContinMotor:ulseOut(servoright,pulse2);
最终要实现的是这俩个方法。
你把获取的参数,retun(0);那是不是等于白做了? 去掉最后的“return(0);”就循环了。
调试程序没有单步跟踪吗? return(0)就是跳出循环,抓急:dizzy: Loop ()在哪里? Arduino不是
void setup() {}
void loop() {}
格式吗
怎么成int main(void)
{
while(1)
{
}
}
页:
[1]