HOME

    Electronics Directory Articles/ Tutorials eBooks

About Us

FORUM Links Contact Us
   

 

 PC Based Quiz Buzzer (Part 3)

By Harsha and Veena

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

 

 

#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