当前位置:网站首页>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;
}
}
边栏推荐
- [Yangcheng cup 2020] easyphp
- 设置单击右键可以选择用VS Code打开文件
- Chow-Liu Tree
- antd组件upload上传xlsx文件,并读取文件内容
- Generics and reflection, this is enough
- 首批 | 腾讯云完成国内首个云原生安全成熟度评估
- Qt QScrollArea
- [chestnut sugar GIS] how does global mapper batch produce ground contour lines through DSM
- Webrtc audio and video capture and playback examples and mediastream media stream analysis
- 1px pixel compatibility of mobile terminal, 1px border
猜你喜欢
China Academy of information technology, Tsinghua University, Tencent security, cloud native security, industry university research and use strong alliance!
Motivation du Protocole de chiffrement avancé AES
Loss function~
Niuke network: maximum submatrix
The first batch of Tencent cloud completed the first cloud native security maturity assessment in China
AES高级加密协议的动机阐述
首批 | 腾讯云完成国内首个云原生安全成熟度评估
Splunk audit setting
mysql重置密码,忘记密码,重置root密码,重置mysql密码
阿里云有奖体验:如何使用 PolarDB-X
随机推荐
LeetCode 968. 监控二叉树
Data analysis learning records -- complete a simple one-way ANOVA with Excel
首批 | 腾讯云完成国内首个云原生安全成熟度评估
Chow-Liu Tree
Lambda表达式:一篇文章带你通透
[chestnut sugar GIS] how does global mapper batch produce ground contour lines through DSM
容器化技术在嵌入式领域的应用
Odoo13 build a hospital HRP environment (detailed steps)
RecyclerView结合ViewBinding的使用
MySQL queries nearby data And sort by distance
The motivation of AES Advanced Encryption Protocol
Innovation strength is recognized again! Tencent security MSS was the pioneer of cloud native security guard in 2022
Potplayer set minimized shortcut keys
Redis 过期策略+conf 记录
创新实力再获认可!腾讯安全MSS获2022年度云原生安全守护先锋
中国信通院、清华大学、腾讯安全,云原生安全产学研用强强联合!
地平线2022年4月最新方案介绍
为什么RTOS系统要使用MPU?
SQL advanced syntax
程序员版本的八荣八耻~