当前位置:网站首页>Eight bit responder [51 single chip microcomputer]
Eight bit responder [51 single chip microcomputer]
2022-07-02 23:11:00 【The universe is hidden in the book】
Design purpose : Design an eight way responder , The rush time is 30S count down , After grabbing it , Yes 10S Time to answer questions 
#include <reg52.h>
#include <absacc.h>
unsigned char code SEG[10]={
0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};// Broken code table of digital tube , Common Yin level
unsigned char dispbuf[2]={
0,0}; // Display 100 bits of buffer
unsigned char flag=0; //1s To the flag
sbit setting=P3^0;
sbit opening=P3^1;
sbit beep=P3^7;
unsigned char number;// Store the key answering number
unsigned char m;
unsigned char mm=30;// Store answers 30 second
/* Timer initialization function @ Peng Wangchong */
void delay();
void display(unsigned char m);
unsigned char anjian();// Function declaration
void Timer0_Init()
{
TMOD=0x01; // Timer 0 The way 1
TH0=(65536-5000)/256; // timing 5ms
TL0=(65536-5000)%256;
ET0=1; // Open the interrupt
EA=1;
TR0=1; // Turn on the timer 0
}
void Timer0_ISR() interrupt 1 using 0
{
static unsigned char i=0,k=0;// among m and mm Respectively 5 Second countdown and 30 Second countdown
TH0=(65536-5000)/256; // Reset the initial value
TL0=(65536-5000)%256;
k++;
if(k==200)
{
k=0;
if(mm==0)
mm=0;
else
mm--;
}
if(mm==3)
{
for(m=3;m--;m>0)
{
beep=!beep;
delay();}
}
P1=0xff;// Turn off the nixie tube
if(i==2)
P1=SEG[number];
else
P1=SEG[dispbuf[i]];
P3 = ~(0x08<<i);
i++;
if(i==3)
i=0;
display(mm);
}
void display(unsigned char m)
{
dispbuf[1]= m/10 ; // Get ten
dispbuf[0]= m%10 ; // Get bits
}
// Salt water
void delay()
{
unsigned char i;
for(i=0;i<120;i++); // Time delay 1ms
}
void main()
{
Timer0_Init();
while(1)
{
if(opening==0)
mm=30;
if(P2!=0xff)// If a key is pressed , Then return the key value
{
number=anjian();
mm=10;
while(1)
{
if(opening==0)
{
mm=30;number=0;break;}
}
}
}
}
// Case handling function
unsigned char anjian()
{
switch(P2)
{
case 0xfe:return 1;break;
case 0xfd:return 2;break;
case 0xfb:return 3;break;
case 0xf7:return 4;break;
case 0xef:return 5;break;
case 0xdf:return 6;break;
case 0xbf:return 7;break;
case 0x7f:return 8;break;
default:return 0;
}
}
边栏推荐
- To myself who is about to work
- Jerry's built-in short press and long press, no matter how long it is, it is a short press [chapter]
- mysql重置密码,忘记密码,重置root密码,重置mysql密码
- Static file display problem
- 【硬件】标准阻值的由来
- Xshell configuration xforward forwarding Firefox browser
- China Academy of information technology, Tsinghua University, Tencent security, cloud native security, industry university research and use strong alliance!
- WebRTC音视频采集和播放示例及MediaStream媒体流解析
- 4 special cases! Schools in area a adopt the re examination score line in area B!
- MySQL查询附近的数据.并按距离进行排序.
猜你喜欢

最小生成树 Minimum Spanning Tree

Jinglianwen technology's low price strategy helps AI enterprises reduce model training costs

中国信通院、清华大学、腾讯安全,云原生安全产学研用强强联合!

LeetCode 968. 监控二叉树

海思 VI接入视频流程

解决Chrome浏览器和Edeg浏览器主页被篡改的方法

Introduction to the latest plan of horizon in April 2022

景联文科技低价策略帮助AI企业降低模型训练成本

Go语言sqlx库操作SQLite3数据库增删改查

实现BottomNavigationView和Navigation联动
随机推荐
Generics and reflection, this is enough
Lambda表达式:一篇文章带你通透
AES高级加密协议的动机阐述
Successfully changed Splunk default URL root path
电路设计者常用的学习网站
pytorch训练CPU占用持续增长(bug)
泛型与反射,看这篇就够了
Alibaba cloud award winning experience: how to use polardb-x
Doorplate making C language
Redis 过期策略+conf 记录
创新实力再获认可!腾讯安全MSS获2022年度云原生安全守护先锋
LeetCode 968. 监控二叉树
深度剖析数据在内存中的存储----C语言篇
xshell配置xforward转发火狐浏览器
20220527_数据库过程_语句留档
Value sequence < detailed explanation of daily question >
静态文件显示问题
Jerry's built-in short press and long press, no matter how long it is, it is a short press [chapter]
力扣刷题(2022-6-28)
Chow-Liu Tree