当前位置:网站首页>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;
}
}
边栏推荐
- Motivation du Protocole de chiffrement avancé AES
- Looking at Ctrip's toughness and vision from the Q1 financial report in 2022
- Freshman learning sharing
- Solving ordinary differential equations with MATLAB
- Typical case of data annotation: how does jinglianwen technology help enterprises build data solutions
- Doorplate making C language
- 海思3559万能平台搭建:在截获的YUV图像上旋转操作
- How does Jerry test the wrong touch rate of keys [chapter]
- 深度剖析数据在内存中的存储----C语言篇
- 解决Chrome浏览器和Edeg浏览器主页被篡改的方法
猜你喜欢

STM32之ADC

LeetCode 968. Monitor binary tree

MySQL queries nearby data And sort by distance

Generics and reflection, this is enough

Redis 过期策略+conf 记录

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

为什么RTOS系统要使用MPU?
![[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

LeetCode 968. 监控二叉树

阿里云有奖体验:如何使用 PolarDB-X
随机推荐
海思3559万能平台搭建:在截获的YUV图像上旋转操作
Jerry's built-in short press and long press, no matter how long it is, it is a short press [chapter]
Jielizhi, production line assembly link [chapter]
解决Chrome浏览器和Edeg浏览器主页被篡改的方法
情感对话识别与生成简述
Qt QScrollArea
LeetCode 968. 监控二叉树
MySQL reset password, forget password, reset root password, reset MySQL password
设置单击右键可以选择用VS Code打开文件
Potplayer set minimized shortcut keys
Cryptographic technology -- key and ssl/tls
Qt QSplitter拆分器
Splunk audit 的设定
Introduction to the latest plan of horizon in April 2022
移动端 1px 像素兼容性问题,实现1px 边框
最小生成树 Minimum Spanning Tree
为什么RTOS系统要使用MPU?
Tronapi wave field interface - source code without encryption - can be opened twice - interface document attached - packaging based on thinkphp5 - detailed guidance of the author - July 1, 2022 08:43:
Jinglianwen technology's low price strategy helps AI enterprises reduce model training costs
[npuctf2020]ezlogin XPath injection