完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
#include #include #define uint unsigned int #define uchar unsigned char ***it K1=P2^0; //模式 ***it K2=P2^1; //加速 ***it K3=P2^3; //减速 uint K=0; uchar code table[8]={ 0xc0,0xf9,0xa4,0xb0, 0x99,0x92,0xb2,0xf8,}; void delay(uint z)//延迟函数 { uint x,y; for(x=0;x<=z;x++) for(y=0;y<=100;y++); } void model(uint T) //模式的选择 { switch(T) { case 1: { uint temp1,num1; temp1=0xff7f; P3=table[1]; for(num1=0;num1<16;num1++) { P1=temp1/256; P0=temp1%256; temp1=_iror_(temp1,1); delay(1000); } }break; case 2: { uint temp2,num2; temp2=0xfeff; P3=table[2]; for(num2=0;num2<16;num2++) { P1=temp2/256; P0=temp2%256; temp2=_irol_(temp2,1); delay(1000); } }break; case 3: { uint temp3,num3; temp3=0x0100; P3=table[3]; for(num3=0;num3<16;num3++) { P1=temp3/256; P0=temp3%256; temp3=_irol_(temp3,1); delay(1000); } }break; case 4: { uint temp4,num4; temp4=0x0100; P3=table[4]; for(num4=0;num4<16;num4++) { P1=temp4/256; P0=temp4%256; temp4=_iror_(temp4,1); delay(1000); } }break; case 5: { uint temp5,num5; temp5=0x0080; P3=table[5]; for(num5=0;num5<16;num5++) { P1=temp5/256; P0=temp5%256; temp5=_iror_(temp5,1); delay(1000); } }break; default:{ P3=table[0];P0=0xff;P1=0xff;} } } uint mcount()//模式的计数 { if(K1==0) { delay(5); if(K1==0) { K++; if(K==6) { K=0; } } } while(!K1); } uint acount()//加速的计数 { } void main() { while(1) { model(mcount); } } 这个程序我只完成了模式选择,但是我按按钮的时候不知道为什么只有模式1启动其他的却没什么反应。求指教。
|
|
相关推荐 |
|
只有小组成员才能发言,加入小组>>
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 22:34 , Processed in 0.408515 second(s), Total 37, Slave 27 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
23873
