蛋痛创意:为了对抗邪恶的喵星人
最近,实在是被家里的喵星人欺负的忍无可忍了,决心奋起反击!!要对抗喵星人的暴政,那当然是请老虎出马!
不知道这是什么东东的,请去看《狂怒》---(斑竹,这个不是广告吧?)
初步的想定是:
Plan A:用电脑遥控这只车子,实现3个进档,3个退档,3个转向档以及它们的组合而成的48种运动模式,炮塔和炮管可以转动,可以打BB弹驱逐猫咪。硬件部分使用的是成品,主要是实现控制改造。
Plan B:将老虎接入到家庭WIFI网络,这样,我就可以在安全屋里操作它了,嘿嘿嘿嘿,老虎上加装数传摄像机,包括航向摄像机和并列摄像机,当然,后面那只就是用来开炮滴。
Plan C:在家里的公共区域安装摄像机,编制视频搜索算法,主动识别喵星人并操作老虎赶来镇压,哈哈哈哈哈哈哈哈......我得意的笑
目前进度:
老虎的机械部分已经修理完毕,车体和炮塔都可以动作了。
切除了老虎体内的电池舱,为改装大电池和控制板做好了准备。
uno和298的联调已经完成,目前通过无线串口已经可以发送指令到298的输出了。
下一个节点:
焊接线路,车体组装,预计本周完成。
一切被喵星人压榨的弟兄,联合起来,发出我们自己的怒吼吧:lol
本帖最后由 wb9999cn 于 2014-12-2 20:25 编辑
/***************坦克运行部分控制模型*********************
******************车体运行命令列表***********************
命令前进后退左弯右弯行进档 转向档 左电机 右电机
1 接通 一档 30% 30%
2 接通 二档 70% 70%
3 接通 三档 100%100%
4 接通 一档 -30%-30%
5 接通 二档 -70%-70%
6 接通 三档 -100% -100%
7 接通 一档 0% 50%
8 接通 二档 0% 100%
9 接通 三档 -50%50%
10 接通 一档 50% 0%
11 接通 二档 100%0%
12 接通 三档 50% -50%
13接通 接通 一档一档20% 50%
14接通 接通 二档一档35% 65%
15接通 接通 三档一档50% 80%
16接通 接通 一档二档20% 60%
17接通 接通 二档二档35% 75%
18接通 接通 三档二档50% 90%
19接通 接通 一档三档20% 70%
20接通 接通 二档三档35% 85%
21接通 接通 三档三档50% 100%
22接通 接通一档一档50% 20%
23接通 接通二档一档65% 35%
24接通 接通三档一档80% 50%
25接通 接通一档二档60% 20%
26接通 接通二档二档75% 35%
27接通 接通三档二档90% 50%
28接通 接通一档三档70% 20%
29接通 接通二档三档85% 35%
30接通 接通三档三档100%50%
31 接通接通 一档一档-20%-50%
32 接通接通 二档一档-35%-65%
33 接通接通 三档一档-50%-80%
34 接通接通 一档二档-20%-60%
35 接通接通 二档二档-35%-75%
36 接通接通 三档二档-50%-90%
37 接通接通 一档三档-20%-70%
38 接通接通 二档三档-35%-85%
39 接通接通 三档三档-50%-100%
40 接通 接通一档一档-50%-20%
41 接通 接通二档一档-65%-35%
42 接通 接通三档一档-80%-50%
43 接通 接通一档二档-60%-20%
44 接通 接通二档二档-75%-35%
45 接通 接通三档二档-90%-50%
46 接通 接通一档三档-70%-20%
47 接通 接通二档三档-85%-35%
48 接通 接通三档三档-100% -50%
49 0% 0% 停车
******************炮塔运行命令列表***********************
命令左转右转抬高降低转速档 方向机高低机
51 接通 一档40%
52 接通 二档70%
53 接通 三档100%
54 接通 一档-40%
55 接通 二档-70%
56 接通 三档-100%
57 接通 一档 40%
58 接通 二档 70%
59 接通 三档 100%
60 接通 一档 -40%
61 接通 二档 -70%
62 接通 三档 -100%
63 0 0
*****************火炮运行命令列表***********************
命令开火档 火炮机
91 一档 0%
92 二档 50%
93 三档 100%
******************变量声明****************************/
String comdata = ""; //定义字符串
int mark = 0; //定义接收数据的标识
int numdata = 0; //定义串口收到的数值
int E1 = 3; //左驱动电机模拟口
int M1 = 4; //左驱动电机数字口
int E2 = 5; //右驱动电机模拟口
int M2 = 7; //右驱动电机数字口
int E3 = 6; //炮塔方向电机模拟口
int M3 = 8; //炮塔方向电机数字口
int E4 = 9; //炮管高低电机模拟口
int M4 = 12;//炮管高低电机数字口
int E5 = 10;//火炮驱动电机模拟口
int M5 = 13;//火炮驱动电机数字口
int command; //定义命令
int drive; //定义驾驶状态要求
int oldDrive;//定义行驶状态
int turret; //定义炮塔状态要求
int oldTurret;//定义炮塔状态
int cannon; //定义射击状态要求
int oldCannon;//定义射击状态
/****************程序初始化***********************/
void setup()
{
pinMode(E1,OUTPUT); //设置电机驱动接口状态
pinMode(M1,OUTPUT);//设置电机驱动接口状态
pinMode(E2,OUTPUT);//设置电机驱动接口状态
pinMode(M2,OUTPUT);//设置电机驱动接口状态
pinMode(E3,OUTPUT);//设置电机驱动接口状态
pinMode(M3,OUTPUT);//设置电机驱动接口状态
pinMode(E4,OUTPUT);//设置电机驱动接口状态
pinMode(M4,OUTPUT);//设置电机驱动接口状态
pinMode(E5,OUTPUT);//设置电机驱动接口状态
pinMode(M5,OUTPUT);//设置电机驱动接口状态
Serial.begin(9600); //打开串口
}
/****************主程序***********************/
void loop()
{
/********不断循环检测串口缓存,一个个读入字符串*********/
while (Serial.available() > 0) //如果有串口数据
{
comdata += char(Serial.read());//读入之后将字符串,串接到comdata上面。
delay(2); //延时
mark = 1; //标记串口读过数据
}
/*****************将字符串转化为数值和命令**********************/
if(mark == 1)//如果接收到数据
{
for(int i = 0; i < comdata.length() ; i++) //以串口读取字符串长度循环,
{
numdata = numdata * 10 + (comdata - '0');//将字符串转化为数值
}
command = numdata; //读取命令
Serial.print("command="); //输出命令
Serial.println(command); //输出命令内容
comdata = String(""); //清空comdata
numdata = 0; //给numdata赋值0
mark = 0; //给mark赋值0
}
/***************将命令转化为动作*****************/
switch(command)
{
/***************车体动作*****************/
case 1: //命令1
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 63); //30%
analogWrite(E2, 63); //30%
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 2:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 127); //PWM调速
analogWrite(E2, 127); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 3:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 254); //PWM调速
analogWrite(E2, 254); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 4:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 63); //PWM调速
analogWrite(E2, 63); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 5:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 127); //PWM调速
analogWrite(E2, 127); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 6:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 254); //PWM调速
analogWrite(E2, 254); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 7:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 0); //PWM调速
analogWrite(E2, 127); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 8:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 0); //PWM调速
analogWrite(E2, 254); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 9:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,LOW); //
analogWrite(E1, 127); //PWM调速
analogWrite(E2, 127); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 10:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 127); //PWM调速
analogWrite(E2, 0); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 11:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 254); //PWM调速
analogWrite(E2, 0); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 12:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 127); //PWM调速
analogWrite(E2, 127); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 13:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 50); //PWM调速
analogWrite(E2, 127); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 14:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 89); //PWM调速
analogWrite(E2, 165); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 15:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 127); //PWM调速
analogWrite(E2, 204); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 16:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 50); //PWM调速
analogWrite(E2, 152); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 17:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 89); //PWM调速
analogWrite(E2, 192); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 18:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 127); //PWM调速
analogWrite(E2, 229); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 19:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 50); //PWM调速
analogWrite(E2, 178); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 20:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 89); //PWM调速
analogWrite(E2, 216); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 21:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 127); //PWM调速
analogWrite(E2, 255); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 22:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 127); //PWM调速
analogWrite(E2, 50); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 23:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 165); //PWM调速
analogWrite(E2, 89); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 24:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 204); //PWM调速
analogWrite(E2, 127); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 25:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 152); //PWM调速
analogWrite(E2, 50); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 26:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 192); //PWM调速
analogWrite(E2, 89); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 27:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 229); //PWM调速
analogWrite(E2, 127); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 28:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 178); //PWM调速
analogWrite(E2, 50); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 29:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 216); //PWM调速
analogWrite(E2, 89); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 30:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 255); //PWM调速
analogWrite(E2, 127); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 31:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 50); //PWM调速
analogWrite(E2, 127); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 32:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 89); //PWM调速
analogWrite(E2, 165); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 33:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 127); //PWM调速
analogWrite(E2, 204); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 34:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 50); //PWM调速
analogWrite(E2, 152); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 35:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 89); //PWM调速
analogWrite(E2, 192); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 36:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 127); //PWM调速
analogWrite(E2, 229); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 37:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 50); //PWM调速
analogWrite(E2, 178); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 38:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 89); //PWM调速
analogWrite(E2, 216); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 39:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 127); //PWM调速
analogWrite(E2, 255); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 40:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 127); //PWM调速
analogWrite(E2, 50); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 41:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 165); //PWM调速
analogWrite(E2, 89); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 42:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 204); //PWM调速
analogWrite(E2, 127); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 43:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 152); //PWM调速
analogWrite(E2, 50); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 44:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 192); //PWM调速
analogWrite(E2, 89); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 45:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 229); //PWM调速
analogWrite(E2, 127); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 46:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 178); //PWM调速
analogWrite(E2, 50); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 47:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 216); //PWM调速
analogWrite(E2, 89); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
case 48:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,HIGH); //
digitalWrite(M2,HIGH); //
analogWrite(E1, 255); //PWM调速
analogWrite(E2, 127); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
/*******??????????????????????????????????***********/
case 49:
drive = command;
if(drive != oldDrive)
{
digitalWrite(M1,LOW); //
digitalWrite(M2,LOW); //
analogWrite(E1, 0); //PWM调速
analogWrite(E2, 0); //PWM调速
oldDrive = drive; //刷新行驶状态
Serial.print("drive=");
Serial.println(drive);
}
break;
/***************炮塔动作*******************/
case 51:
turret = command;
if(turret != oldTurret)
{
digitalWrite(M3,LOW); //
analogWrite(E3, 63); //PWM调速
oldTurret = turret; //刷新行驶状态
Serial.print("turret=");
Serial.println(turret);
}
break;
case 52:
turret = command;
if(turret != oldTurret)
{
digitalWrite(M3,LOW); //
analogWrite(E3, 127); //PWM调速
oldTurret = turret; //刷新行驶状态
Serial.print("turret=");
Serial.println(turret);
}
break;
case 53:
turret = command;
if(turret != oldTurret)
{
digitalWrite(M3,LOW); //
analogWrite(E3, 254); //PWM调速
oldTurret = turret; //刷新行驶状态
Serial.print("turret=");
Serial.println(turret);
}
break;
case 54:
turret = command;
if(turret != oldTurret)
{
digitalWrite(M3,HIGH); //
analogWrite(E3, 63); //PWM调速
oldTurret = turret; //刷新行驶状态
Serial.print("turret=");
Serial.println(turret);
}
break;
case 55:
turret = command;
if(turret != oldTurret)
{
digitalWrite(M3,HIGH); //
analogWrite(E3, 127); //PWM调速
oldTurret = turret; //刷新行驶状态
Serial.print("turret=");
Serial.println(turret);
}
break;
case 56:
turret = command;
if(turret != oldTurret)
{
digitalWrite(M3,HIGH); //
analogWrite(E3, 254); //PWM调速
oldTurret = turret; //刷新行驶状态
Serial.print("turret=");
Serial.println(turret);
}
break;
case 57:
turret = command;
if(turret != oldTurret)
{
digitalWrite(M4,LOW); //
analogWrite(E4, 63); //PWM调速
oldTurret = turret; //刷新行驶状态
Serial.print("turret=");
Serial.println(turret);
}
break;
case 58:
turret = command;
if(turret != oldTurret)
{
digitalWrite(M4,LOW); //
analogWrite(E4, 127); //PWM调速
oldTurret = turret; //刷新行驶状态
Serial.print("turret=");
Serial.println(turret);
}
break;
case 59:
turret = command;
if(turret != oldTurret)
{
digitalWrite(M4,LOW); //
analogWrite(E4, 254); //PWM调速
oldTurret = turret; //刷新行驶状态
Serial.print("turret=");
Serial.println(turret);
}
break;
case 60:
turret = command;
if(turret != oldTurret)
{
digitalWrite(M4,HIGH); //
analogWrite(E4, 63); //PWM调速
oldTurret = turret; //刷新行驶状态
Serial.print("turret=");
Serial.println(turret);
}
break;
case 61:
turret = command;
if(turret != oldTurret)
{
digitalWrite(M4,HIGH); //
analogWrite(E4, 127); //PWM调速
oldTurret = turret; //刷新行驶状态
Serial.print("turret=");
Serial.println(turret);
}
break;
case 62:
turret = command;
if(turret != oldTurret)
{
digitalWrite(M4,HIGH); //
analogWrite(E4, 254); //PWM调速
oldTurret = turret; //刷新行驶状态
Serial.print("turret=");
Serial.println(turret);
}
break;
case 63:
turret = command;
if(turret != oldTurret)
{
digitalWrite(M3,LOW); //
digitalWrite(M4,LOW); //
analogWrite(E3, 0); //PWM调速
analogWrite(E4, 0); //PWM调速
oldTurret = turret; //刷新行驶状态
Serial.print("turret=");
Serial.println(turret);
}
break;
/***************射击动作*******************/
case 91:
cannon = command;
if(cannon != oldCannon)
{
digitalWrite(M5,LOW); //
analogWrite(E5, 0); //PWM调速
oldCannon = cannon; //刷新行驶状态
Serial.print("cannon=");
Serial.println(cannon);
}
break;
case 92:
cannon = command;
if(cannon != oldCannon)
{
digitalWrite(M5,LOW); //
analogWrite(E5, 127); //PWM调速
oldCannon = cannon; //刷新行驶状态
Serial.print("cannon=");
Serial.println(cannon);
}
break;
case 93:
cannon = command;
if(cannon != oldCannon)
{
digitalWrite(M5,LOW); //
analogWrite(E5, 254); //PWM调速
oldCannon = cannon; //刷新行驶状态
Serial.print("cannon=");
Serial.println(cannon);
}
break;
}
}
车体行动部分的代码基本上写完了,不过,由于第一次写Arduino的程序,因此感觉非常累赘,估计有很多技巧和函数可以大幅度精简代码。先不管了,还是发上来供大家批判,如果有大神能指点一下精简代码的思路,不胜感激。 喵王 发表于 2014-12-2 10:21
视频传输你打算怎么实现?而且是两路视频传输哦。
是哦传输全部用WIFI。
实际上,虽然目前我用的是APC220数传,但是最终我也会将坦克的控制部分放进WIFI网络的。我要实现的目标是非接触战争啊:lol
我在关上门的主卧室里面操作坦克去与占领了客厅沙发的喵星人战斗。
最终的目标是在客厅安装摄像机,通过动态目标分离的方式,直接引导坦克作战,可以完全无人操作。当然,还是要人在回路中,以防失控。这一步-----可以理解,还很远。 本帖最后由 wb9999cn 于 2014-12-4 23:50 编辑
进度汇报:
(1)坦克底甲板制作完成,材料为洞洞板,覆盖了整个坦克底部,目的是增加底板强度,bing 电池和电路板提供安装支撑。
(2)电池和电路板固定方式已经确定,并进行了假组合,以便确认没有与坦克炮塔和火炮之间的干涉可能。原来考虑的三块电机驱动板层叠的方式放弃了,高度不够,只好在电池上面加了一层电路板。
下步工作安排:周末完成焊接。:victory:
哈哈哈,坦克相当给力啊~让喵星人更惧怕的是在你的坦克上面加一个MP3模块,然后模拟各种狗叫,哈哈哈,喵星人一定会毛孔数起来滴,哈哈哈哈 俺家有汪星人的,也是喵星人的欺压对象啊....... 有个建议,在tank上装个激光笔,然后能自由转动,照到地上,保证猫星人抓狂。。完全抓狂。哈哈 可以做个左右摇晃的东西,这样就可以引诱喵星人过来,然后再吓尿他 视频传输你打算怎么实现?而且是两路视频传输哦。 用wifi摄像头实现视频传输。 时代变了,喵星人称霸,汪星人直接被鄙视了:L:L:L 楼主,喵星人的左眼已经发绿,耳朵竖的很直,明显是要和你挑战了。 哈哈哈哈哈哈笑尿
喵星人这么萌你们不要黑它~~~
楼主家居然还有汪星人,每天的生活一定很嗨森(鸡飞狗跳神马的
如果能在坦克上装摄像头,第一视角看一定很销魂哈哈哈~ 这个。。。。。 吓猫焉用坦克... 楼主,猫需要御的。要是我这的猫,你的坦克直接被啃碎了 fangrong 发表于 2014-12-4 23:41
楼主,猫需要御的。要是我这的猫,你的坦克直接被啃碎了
这个......咱暂时不考虑与山猫、豹猫之类的喵星人中的战斗猫作战的问题。:L 这个坦克确实挺有创意的,楼主的武器装备看来花了不少大洋啊 最新进度:车体已经全部搞定,目前已经可以通过串口调试器来操作它了。
发现的最新问题是电动机扭矩不够,低档下几乎没有行动能力。是不是要换电机了....琢磨算计口袋中的银票
测试战斗表明,猫咪对这个新出现的地面不明爬行物颇有些恐惧.....尤其是在它发射BB弹的时候,嘿嘿,一溜烟跑回自己小窝里躲起来了。 wb9999cn 发表于 2014-12-7 22:30
最新进度:车体已经全部搞定,目前已经可以通过串口调试器来操作它了。
发现的最新问题是电动机扭矩不够, ...
你让可怜的喵星人幼小的心灵受到了惊吓啊 从此抑郁了怎么办.. 这工程量不小啊
页:
[1]
2