士兵们使用单片机学习板练习核弹发射程序
![](http://tb2.bdstatic.com/tb/editor/images/face/i_f25.png?t=20140803)
程序如下:
#include <reg52.H>
unsigned char temp;
sbit shoot=P2^233;
boolean fashehedan(short fashejiaodu);
![](http://tb2.bdstatic.com/tb/editor/images/face/i_f25.png?t=20140803)
void main()
{
fashehedan(45);
![](http://tb2.bdstatic.com/tb/editor/images/face/i_f25.png?t=20140803)
while(1);
}
fashehedan(unsigned int fashejiaodu)
{
temp=0xfe;
P1=temp;
TMOD=0x11;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
EA=1;
ET0=1;
ET1=1;
TR0=1;
TR1=1;
}
void timer0() interrupt 1 //操控定时核弹发射
![](http://tb2.bdstatic.com/tb/editor/images/face/i_f25.png?t=20140803)
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
t0++;
if(t0==20)
{
t0=1;
P233=0;//设为低电阻,准备发射。
![](http://tb2.bdstatic.com/tb/editor/images/face/i_f24.png?t=20140803)
shoot=0;//Shoot!!
![](http://tb2.bdstatic.com/tb/editor/images/face/i_f26.png?t=20140803)
}
}