当前位置:网站首页>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;
}
}
边栏推荐
- Realize the linkage between bottomnavigationview and navigation
- 详解Promise使用
- WebRTC音视频采集和播放示例及MediaStream媒体流解析
- Use of recyclerview with viewbinding
- Potplayer set minimized shortcut keys
- 聊聊内存模型与内存序
- 海思3559万能平台搭建:在截获的YUV图像上画框
- Innovation strength is recognized again! Tencent security MSS was the pioneer of cloud native security guard in 2022
- Analyse des données dossiers d'apprentissage - - analyse simple de la variance à facteur unique avec Excel
- Deep analysis of data storage in memory - C language
猜你喜欢

详解Promise使用
![[favorite poems] OK, song](/img/1a/e4a4dcca494e4c7bb0e3568f708288.png)
[favorite poems] OK, song

密码技术---分组密码的模式

4 special cases! Schools in area a adopt the re examination score line in area B!

Set right click to select vs code to open the file

数据标注典型案例,景联文科技如何助力企业搭建数据方案

情感对话识别与生成简述
![[chestnut sugar GIS] ArcScene - how to make elevation map with height](/img/91/f3df0a7633263c6264cb5c27eb149f.png)
[chestnut sugar GIS] ArcScene - how to make elevation map with height

Chow-Liu Tree

从底层结构开始学习FPGA----Xilinx ROM IP的定制与测试
随机推荐
实现BottomNavigationView和Navigation联动
Go multithreaded data search
Introduction to the latest plan of horizon in April 2022
Successfully changed Splunk default URL root path
Use the scroll bar of souI when using the real window in souI
Learning Websites commonly used by circuit designers
最小生成树 Minimum Spanning Tree
Start from the bottom structure to learn the customization and testing of FPGA --- Xilinx ROM IP
Jielizhi, production line assembly link [chapter]
Jerry's prototype will trigger shutdown after multiple touches [chapter]
SQL进阶语法
P1007 single log bridge
Ping domain name error unknown host, NSLOOKUP / system d-resolve can be resolved normally, how to Ping the public network address?
Jerry's prototype has no touch, and the reinstallation becomes normal after dismantling [chapter]
Editor Caton
在SOUI里使用真窗口时使用SOUI的滚动条
Configuration clic droit pour choisir d'ouvrir le fichier avec vs Code
Realize the linkage between bottomnavigationview and navigation
AES高級加密協議的動機闡述
景联文科技低价策略帮助AI企业降低模型训练成本