完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
|
相关推荐
4个回答
|
|
参照51的思路去写,
|
|
|
|
就是没学过51啊、、我现在陆陆续续写了一些,但是就是一直实现不了,可以帮我更改下吗 |
|
|
|
#include
#include "lcd.h" unsigned char uchar; unsigned int uint; //蜂鸣器 unsigned char Buzzer (void) { P6DIR |=BIT4; //蜂鸣器 P6OUT&=~BIT4; //关蜂鸣器 } //复位键 unsigned char Key_pressed1(void) { P6DIR |=BIT5; } void hscan_init() { //行输入 上拉 P6DIR&=~(BIT0+BIT1+BIT2+BIT3); P6OUT |= BIT0+BIT1+BIT2+BIT3; P6REN |= BIT0+BIT1+BIT2+BIT3; //列输出 P1DIR |= BIT2+BIT3+BIT4+BIT5; P1OUT &=~(BIT2+BIT3+BIT4+BIT5); } void lscan_init() { //列输入 上拉 P1DIR &=~(BIT2+BIT3+BIT4+BIT5); P1OUT |= BIT2+BIT3+BIT4+BIT5; P1REN |= BIT2+BIT3+BIT4+BIT5; //行输出 P6DIR |= BIT0+BIT1+BIT2+BIT3; P6OUT &=~(BIT0+BIT1+BIT2+BIT3); } void keyscan() { unsigned char h,l; h=0;l=0; hscan_init(); h=P6IN&(BIT0+BIT1+BIT2+BIT3); lscan_init(); l=P1IN&(BIT2+BIT3+BIT4+BIT5); switch(h) { case 14:h=0; break; case 13:h=1; break; case 11:h=2; break; case 7 :h=3; break; default: h=16;break; } switch(l) { case 224:l=0; break;//11100000 case 208:l=1; break;//11010000 case 176:l=2; break;// case 112:l=3; break; default: l=16;break; } if(h!=16&&l!=16) key_val=h*4+l; } //显示键位和倒计时 unsigned char number[] = {15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0}; void main(void) { WDTCTL=WDTPW+WDTHOLD; LCDinint(); keyscan(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[15]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[14]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[13]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[12]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[11]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[10]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[9]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[8]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[7]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[6]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[5]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[4]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[3]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[2]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[1]+0x30); clearlcd(); LCD_write(key_val+0x30); lcd_pos(0x40); LCD_write(number[0]+0x30); Buzzer(); Key_pressed1(); } |
|
|
|
这是我们弄的代码,求指导
|
|
|
|
只有小组成员才能发言,加入小组>>
3029个成员聚集在这个小组
加入小组2919 浏览 1 评论
MSP430FR5994 使用库函数 定时器触发AD问题请教
3582 浏览 2 评论
请问怎么把下面51单片机的代码改成msp430 g2 pocket的代码,还有改下时间变成30秒
2338 浏览 1 评论
4798 浏览 1 评论
2572 浏览 1 评论
1320浏览 3评论
MSP430FR5994 使用库函数 定时器触发AD问题请教
3582浏览 2评论
2919浏览 1评论
1496浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 12:21 , Processed in 1.246396 second(s), Total 87, Slave 69 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号