当前位置:网站首页>Simulation of four way responder based on 51 single chip microcomputer
Simulation of four way responder based on 51 single chip microcomputer
2022-07-29 08:11:00 【Half life fireworks I blurred】
When the host presses the start button , Start countdown 60 second , The contestants began to rush to answer , When a contestant vies for answers, other contestants' vies for answers are invalid .
And the countdown stops after the contestants rush to answer .
Because I didn't set a new round of buttons , If you need to use a new round of answering, you can add a button to start a new round of answering
Timer configuration code
#include <REGX52.H>
void Timer0_Init(void)
{
TMOD &= 0xF0; // Configure timer mode
TMOD |= 0x01; // Set the timer 0 Pattern
TL0 = 0x3c; // Set initial value of timing 50ms Create an interrupt
TH0 = 0xb0; // Set initial value of timing
TF0 = 0; // eliminate TF0 sign
TR0 = 1; // Timer 0 Start timing
ET0=1;
EA=1;
PT0=0;
}
The digital tube displays the contestant number code
#include <REGX52.H>
#include "Delay.h" // contain Delay The header file
sbit we1=P2^0;
// Digital tube segment code table
unsigned char Table[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
// Nixie tube display sub function
void Nixie(unsigned int Speed)
{
we1=0;
P0=Table[Speed]; // Segment code output
Delay(1); // Show for a period of time
we1=1;
P0=0x00; // Segment code clear 0, Shadow elimination
}
The main function 、 Interrupt service function 、 Nixie tube display countdown
#include <REGX52.H>
#include "Delay.h"
#include "Timer0.h"
#include "Nixie.h"
unsigned char NixieTable[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};// Common cathode digital tube segment code
sbit we3=P2^2;
sbit we4=P2^3;
unsigned int flag=0,ms=60;//ms Set the initial value of countdown
unsigned int Number=0;
unsigned int x,z,y=0,f=0;
void main()
{
Timer0_Init();
while(1)
{
if(P1_4==0)
{
Delay(20);while(P1_4==0);Delay(20);
y=1;// Countdown start flag bit ,1 Start countdown
flag=1;// Answer the flag bit ,1 Key valid ,0 Invalid key
}
x=ms/10;
z=ms-x*10;// Count down each bit of data into the digital tube display
we3=0;
P0=NixieTable[x]; // Segment code output
Delay(1); // Show for a period of time
we3=1;
P0=0x00; // Segment code clear 0, Shadow elimination
we4=0;
P0=NixieTable[z]; // Segment code output
Delay(1); // Show for a period of time
we4=1;
P0=0x00; // Segment code clear 0, Shadow elimination
if(flag==1)
{
if(P1_0==0)
{
Delay(20);while(P1_0==0);Delay(20);
flag=0;// Make other players unable to answer
Number=1;// Get the contestant number and send it to the nixie tube display
f=1;// The countdown stops
}
if(P1_1==0)
{
Delay(20);while(P1_1==0);Delay(20);
flag=0;
Number=2;
f=1;
}
if(P1_2==0)
{
Delay(20);while(P1_2==0);Delay(20);
flag=0;
Number=3;
f=1;
}
if(P1_3==0)
{
Delay(20);while(P1_3==0);Delay(20);
flag=0;
Number=4;
f=1;
}
}
Nixie(Number);// Nixie tube display function
}
}
void Timer0_Routine() interrupt 1
{
unsigned int T0Count;
TL0 = 0x3c; // Set the initial value of timing to 50ms
TH0 = 0xb0; // Set initial value of timing
T0Count++;
if(T0Count>=20)
{
T0Count=0;
if(f==0)
{
if(y==1)
{
ms--;//1s Subtract one time
if(ms==0)
{
ms=60;
}
}
}
else
{
ms=ms;// The countdown stops after the contestants rush to answer
}
}
}Simulation graphics

The answering machine made this time is relatively simple , If necessary, you can add code to make the function more comprehensive . If there is enough time in the follow-up, it can be further improved .
Just thought about it, I added a new round of answering buttons
if(P1_5==0)
{
Delay(20);while(P1_5==0);Delay(20);
break;// Jump out when the key is pressed while Main circulation
}
边栏推荐
- [beauty of software engineering - column notes] 25 | what methods can improve development efficiency?
- "Swiss Army Knife" -nc in network tools
- Cv520 domestic replacement of ci521 13.56MHz contactless reader chip
- In an SQL file, a test table and data are defined above, and you can select* from the test table below
- Unity beginner 1 - character movement control (2D)
- sql判断语句的编写
- Research on autojs wechat: the final product of wechat automatic information sending robot (effective demonstration)
- Random lottery turntable wechat applet project source code
- V-Ray 5 acescg workflow settings
- Ws2812b color lamp driver based on f407zgt6
猜你喜欢

Simplefoc parameter adjustment 2- speed and position control

C language data type

Security baseline of network security

Privacy is more secure in the era of digital RMB
![[beauty of software engineering - column notes] 27 | what is the core competitiveness of software engineers? (top)](/img/23/288f6c946a44e36ab58eb0555f3650.png)
[beauty of software engineering - column notes] 27 | what is the core competitiveness of software engineers? (top)

Qt/pyqt window type and window flag

Solving linear programming problems based on MATLAB

Unicode私人使用区域(Private Use Areas)
![[paper reading | cryoelectron microscope] interpretation of the new subtomogram averaging method in relion 4.0](/img/8d/03e63d651b713f547b090e6e740b06.png)
[paper reading | cryoelectron microscope] interpretation of the new subtomogram averaging method in relion 4.0

Cv520 domestic replacement of ci521 13.56MHz contactless reader chip
随机推荐
阿里巴巴政委体系-第一章、政委建在连队上
Dp1332e multi protocol highly integrated contactless read-write chip
Crawl notes
An Optimal Buffer Management Scheme with Dynamic Thresholds论文总结
【NOI模拟赛】计算几何(凸包,暴力,并查集)
Nrf52832-qfaa Bluetooth wireless chip
Ws2812b color lamp driver based on f407zgt6
Tle5012b+stm32f103c8t6 (bluepill) reading angle data
STM32 detection signal frequency
Dp1332e multi protocol highly integrated contactless read-write chip
Exercise: store department information
Intelligent shelf safety monitoring system
Simplefoc parameter adjustment 2- speed and position control
(Video + graphic) machine learning introduction series - Chapter 5 machine learning practice
Dynamic Thresholds Buffer Management in a Shared Buffer Packet Switch论文总结
Implementation of simple cubecap+fresnel shader in unity
Mysql rownum 实现
Stm32ff030 replaces domestic MCU dp32g030
[cryoelectron microscope | paper reading] emclarity: software for high-resolution cryoelectron tomography and sub fault averaging
[lecture notes] how to do in-depth learning in poor data?