ssawee的maple收到了。很欣赏Arduino的设计理念,的确是把开发的注意力移到了逻辑上。不过Maple的IDE功能有点弱,没有引用查找也没有自动完成呵呵。在公司的WinXP上用的时候很顺利,可以下载代码到Flash或者RAM中。家里的Win7驱动有点搞,每次重启时设备都会自动弹出然后再插入……导致只能选下载代码到Flash,然后手动重启运行……不知道ssawee有解吗?对了,再问下锂电接口是什么型号的,我需要买个头好接锂电玩……
写了个无聊的“聊天”(只有4句可聊……)程序,附上截图和代码。
char buf[1024]; char *talks[][4]={ {"hi", "hello", "_", "Hello!"}, {"goodbye", "bye", "see you", "See you !"}, {"what is your name", "what's your name", "who are you", "My name is Ming, nice to meet you :D"}, {"how old are you", "how old", "_", "A little to 15."} }; int p = 0;
boolean strlike(char *s1, char *s2){ for(;*s1 > 0 && *s2 > 0; s1++, s2++){ if(*s1 != *s2){ return false; } } return true; }
void command(){ boolean matched = false; for(int i = 0; i < 4 && ! matched; i ++){ char **talk = (char **) *(talks + i); for(int j = 0; j < 3 && ! matched; j ++){ if(strlike(*(talk+j), (char *)buf)){ SerialUSB.println(*(talk+3)); matched = true; } } } if(! matched){ SerialUSB.println("I can not understand what you say."); } SerialUSB.print(">"); }
void setup(){
}
void loop(){ if(SerialUSB.available() > 0){ char in = SerialUSB.read(); if(in == '\r' || in == '\n'){ buf[p++]=0; SerialUSB.println(); command(); p = 0; }else{ buf[p++] = in; SerialUSB.print(in); } } delay(10); }
[ 本帖最后由 elulis 于 2011-1-27 21:59 编辑 ]
|