HOME

    Electronics Directory Articles/ Tutorials eBooks

About Us

FORUM Links Contact Us
   

 

 PC Based Quiz Buzzer (Part 2)

By Harsha and Veena

 

         << Read previous part: PC Based Quiz buzzer: Project tutorial

The multiplexers contain inverters and drivers to apply full on-chip data selections to the four output gates. A separate strobe input is provided. A 4-bit word is selected from one of two sources and is route to the four outputs. these provide buffered inputs and outputs with the propagation time of 9ns as typical.  IC74157  generates four functions of two variables.

 

Pin No.

Description

Purpose

1

Select

Connected to the out port of the PC

15

Enable

Connected to Ground

2,3,5,6,10,11

Inputs

Connected to switches

4,7,9,12

Outputs

Connected to input port of the PC

8

Ground

Common Ground

16

+Vcc

+5V

 

The working can be explained as follows:

 

                The selection line is made high and low alternatively. When the select line goes low, the pins 2,5,14 will be connected to pins 4,7,12 respectively. Similarly when select line goes high pins 3,6,13 will be connected to 4,7,12 respectively.

 

               First by making the select line low, ports are scanned. Now if teams 1, 3, 5 are pressed, it can be detected. Then teams 2, 4 and 6 can be detected by making select line high.

 

               We have used Turbo C graphics to display the numbers. To learn the basic of Turbo C graphics, read this article.

 

 

The main function:

#include<dos.h>
#include<graphics.h>
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>

#define port 0x378

void ready(int);
void qqqq(int,int);
void setscreen (void);
void kbpress (int );
void showteam(int);


int flag[7]={0,0,0,0,0,0};
int mx,my,j=0,order[7];
int team[8][7]={    {1,1,1,0,1,1,1},
                        {0,0,0,0,0,1,1},
                        {0,1,1,1,1,1,0},
                        {0,0,1,1,1,1,1},
                        {1,0,0,1,0,1,1},
                        {1,0,1,1,1,0,1},
                        {1,1,1,1,1,0,1},
                        {0,0,0,0,0,0,0}     }; 

void main()
{
  int gd=DETECT,gm;
  char key;
  int t;

  initgraph(&gd,&gm,"");
  cleardevice();

  mx=getmaxx();
  my=getmaxy();

  setscreen();
/*---------------------------------------------*/
  while(1)
  {
           outportb(port, port | 0x02);
           delay(1);
           t=inportb(port+1);
           if((t&0x80)==0x80 && flag[1]==0) showteam(1);
           delay(1);
           if((t<<2 & 0x80)==0x00 && flag[2]==0) showteam(2);
           delay(1);
           if((t<<3&0x80)==0x00 && flag[3]==0) showteam(3);
           outportb(port, port & 0xfd);
           delay(1);
           t=inportb(port+1);
           if((t & 0x80)==0x80 && flag[6]==0) showteam(6);
           delay(1);
           if((t<<2 & 0x80)==0x00 && flag[5]==0) showteam(5);
           delay(1);
           if((t<<3 & 0x80)==0x00 && flag[4]==0) showteam(4);

           if(kbhit()) kbpress(getch());
  }

}

 

          This part of the code makes the select line high and low alternatively and scans 3 corresponding ports. Note that this is round robin type of poling and there is no priority. Next part of the code contains functions to display the response in a graphical way and handling the key board events.

continue to next part >>

 

Home   |    About Us   |   Articles/ Tutorials   |   Downloads   |   Feedback   |   Links   |   eBooks   |   Privacy Policy
Copyright 2005-2007 electroSofts.com.
webmaster@electroSofts.com