完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
#include
#include "pwm.h" #define uchar unsigned char #define uint unsigned int #define ulong unsigned long ***it l4=P0^0; ***it l3=P0^1; ***it l2=P0^2; ***it l1=P0^3; ***it r1=P0^4; ***it r2=P0^5; ***it r3=P0^6; ***it r4=P0^7; ***it s1 = P1 ^ 0;//无线键盘1 ++ ***it s2 = P1 ^ 1;//无线键盘2 ++ ***it s3 = P1 ^ 2;//无线键盘3 ++ ***it s4 = P1 ^ 3;//无线键盘4 ++ ***it sn = P1 ^ 4;//无线键盘N(中断) ++ 接VT脚 uchar keys; void DELAY_MS (unsigned int a) { unsigned char i; while( --a != 0) { for(i = 0; i < 600; i++); } } //无线键值处理程序(扫描) void key_init( )//键盘初始化程序// { keys = 0; } void key_rxd()//键盘处理程序// { key_init(); if(sn == 1)//查看是否有键被按下 { DELAY_MS(10);//延时去干扰 if(sn == 1) { if(s1 == 1 && s2 == s3 == s4 == 0){keys = 1;}//查找键值并放入寄存器 if(s2 == 1 && s1 == s3 == s4 == 0){keys = 2;} if(s3 == 1 && s1 == s2 == s4 == 0){keys = 3;} if(s4 == 1 && s1 == s2 == s3 == 0){keys = 4;} } while(sn == 1);//按键是否松开 } } void main () { PWM_init(); while(1) { key_rxd(); if(keys == 1)RUN(-50,-50); if(keys == 2)RUN(50,50); if(keys == 3)RUN(-50,50); if(keys == 4)RUN(50,-50); if (P0==0X10) //左1黑 0001 0000 { RUN(105,85); while(l1==1); } else if (P0==0X30) //左12黑 0011 0000 { RUN(105,85); while(l1==1); } else if (P0==0X20) //左2黑 0010 0000 { RUN(130,75); while(l2==1); } else if (P0==0X60) //左23黑 0110 0000 { RUN(130,65); while(l2==1); } else if (P0==0X40) //左3黑 0100 0000 { RUN(150,75); while(l3==1); } else if (P0==0XC0) //左34黑 1100 0000 { RUN(150,75); while(l3==1); } else if (P0==0X80) //左4黑 1000 0000 { RUN(150,15); while(l4==1); } else if (P0==0X08) //右1黑 0000 1000 { RUN(85,105); while(r1==1); } else if (P0==0X0C) //右12黑 0000 1100 { RUN(85,105); while(r1==1); } else if (P0==0X04) //右2黑 0000 0100 { RUN(75,130); while(r2==1); } else if (P0==0X06) //右23黑 0000 0110 { RUN(65,130); while(r2==1); } else if (P0==0X02) //右3黑 0000 0010 { RUN(80,150); while(r3==1); } else if (P0==0X03) //右34黑 0000 0011 { RUN(75,150); while(r3==1); } else if (P0==0X01) //右4黑 0000 0001 { RUN(15,150); while(r4==1); } else if(P0==0X00) // 0000 0000 { RUN(80,80); while(P0==0X00); } else if(P0==0XFF) // 1111 1111 { RUN(-80,-80); while(P0==0XFF); } } } 这个错在哪了,怎么程序写进去之后车不动,遥控也没用 |
|
相关推荐 |
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
龙芯中科胡伟武:3B6600 八核桌面 CPU 性能将达到英特尔中高端酷睿 12~13 代水平
425 浏览 0 评论
树莓派Pico 2发布,搭载RP2350双核RISC-V和Arm Cortex-M33微控制器!
413 浏览 0 评论
嵌入式学习-搭建自己的ubuntu系统之VMware Tools安装
373 浏览 0 评论
嵌入式学习-搭建自己的ubuntu系统之ubuntu系统安装
590 浏览 0 评论
国产芯上运行TinyMaxi轻量级的神经网络推理库-米尔基于芯驰D9国产商显板
648 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
10659 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-8-14 16:21 , Processed in 0.495245 second(s), Total 71, Slave 53 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191