当前位置:网站首页>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;
}
}
边栏推荐
- Go multithreaded data search
- Construction of Hisilicon 3559 universal platform: draw a frame on the captured YUV image
- 成功改变splunk 默认URL root path
- QT qpprogressbar details
- SQL advanced syntax
- AES高級加密協議的動機闡述
- Potplayer set minimized shortcut keys
- ServletContext learning diary 1
- Numerical solution of partial differential equations with MATLAB
- Methods to solve the tampering of Chrome browser and edeg browser homepage
猜你喜欢

Loss function~

海思 VI接入视频流程

从底层结构开始学习FPGA----Xilinx ROM IP的定制与测试

STM32之ADC
![[Solved] Splunk: Cannot get username when all users are selected“](/img/13/1e824c8005701e21fc5b4e73308d53.png)
[Solved] Splunk: Cannot get username when all users are selected“
![[Solved] Splunk: Cannot get username when all users are selected“](/img/13/1e824c8005701e21fc5b4e73308d53.png)
[Solved] Splunk: Cannot get username when all users are selected“

LeetCode 968. 监控二叉树

mysql重置密码,忘记密码,重置root密码,重置mysql密码

Kubernetes uses the host name to allocate the pod on the specified node

PotPlayer设置最小化的快捷键
随机推荐
Generics and reflection, this is enough
Jerry's charge unplugged, unable to touch the boot [chapter]
設置單擊右鍵可以選擇用VS Code打開文件
Easyclick, EC Quanlang network verification source code
Go language sqlx library operation SQLite3 database addition, deletion, modification and query
Alibaba cloud award winning experience: how to use polardb-x
Solving ordinary differential equations with MATLAB
解决Chrome浏览器和Edeg浏览器主页被篡改的方法
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
STM32之ADC
Cryptography -- the mode of block cipher
psnr,ssim,rmse三个指标的定量分析
MySQL查询附近的数据.并按距离进行排序.
【喜欢的诗词】好了歌
Jerry's prototype has no touch, and the reinstallation becomes normal after dismantling [chapter]
【硬件】标准阻值的由来
景联文科技低价策略帮助AI企业降低模型训练成本
门牌制作 C语言
Typical case of data annotation: how does jinglianwen technology help enterprises build data solutions