Add to Favorites    Make Home Page 10497 Online  
 Language Categories  
 Our Services  

Home » C Home » Hardware Interaction Through C Home » Controling digital circuit through computer

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Controling digital circuit through computer
Author ashim
Author Email ashimpal007 [at] rediffmail.com
Description this code access the lpt port.here only 4 of the total 8 pins are used but can be modified for full 8 pins.it has a complete GUI with mouse & keyboard interactive control panel.works well in win98, but not in winxp feel free to send suggestions or report bugs.
Category C » Hardware Interaction Through C
Hits 386765
Code Select and Copy the Code
//author: ashim pal // heritage institute of technology,kolkata // applied electronics and instrumentation engg. (3rd yr.) #include<stdio.h> #include<conio.h> #include<dos.h> #include<graphics.h> #include<stdlib.h> #include<bios.h> #define port 0x0378 char ch; void display(int,int,int,int); void dispbutton(int); void click(int,int,int,int); void status(int,int,int,int); void reset(int*,int*,int*,int*); int x,y,button; union REGS i,o; initmouse() { i.x.ax=0; int86(0x33,&i,&o); return(o.x.ax); } void showmouseptr() { i.x.ax=1; int86(0x33,&i,&o); } void getmousepos(int *button, int *x,int *y) { i.x.ax =3; int86(0x33,&i,&o); *button =o.x.bx; *x=o.x.cx; *y=o.x.dx; } void hidemouseptr() { i.x.ax=2; int86(0x33,&i,&o); } void main() {clrscr(); int s1=0,s2=0,s3=0,s4=0; int gdriver=DETECT,gmode,ercode; initgraph(&gdriver,&gmode,""); ercode=graphresult(); if(ercode!=0){printf("error code:%s",grapherrormsg(ercode)); getch();} display(s1,s2,s3,s4); initmouse();showmouseptr(); while(ch!=27) {getmousepos(&button,&x,&y); if(button==1) {if(x>80&&x<180&&y>100&&y<140)ch='1'; if(x>200&&x<300&&y>100&&y<140)ch='2'; if(x>320&&x<420&&y>100&&y<140)ch='3'; if(x>440&&x<540&&y>100&&y<140)ch='4'; if(x>440&&x<540&&y>300&&y<340)ch=32; if(x>80&&x<180&&y>300&&y<340)ch=27; } if(kbhit())ch=getch(); switch(ch) {case '1':{s1=!s1; click(s1,s2,s3,s4); outportb(port,1);delay(500);outport(port,0); ch='0';break; } case '2':{s2=!s2; click(s1,s2,s3,s4); outportb(port,2);delay(500);outport(port,0); ch='0';break; } case '3':{s3=!s3; click(s1,s2,s3,s4); outportb(port,4);delay(500);outport(port,0); ch='0';break; } case '4':{s4=!s4; click(s1,s2,s3,s4); outportb(port,8);delay(500);outport(port,0); ch='0';break; } case 32:{click(s1,s2,s3,s4); reset(&s1,&s2,&s3,&s4); ch='0';break; } case 27: {click(s1,s2,s3,s4); reset(&s1,&s2,&s3,&s4); closegraph();exit(0);} } } } void display(int s1,int s2,int s3,int s4) {setbkcolor(9);setcolor(1); rectangle(5,5,635,475);rectangle(10,10,630,470); dispbutton(1);dispbutton(2);dispbutton(3);dispbutton(4); dispbutton(5);dispbutton(6); status(s1,s2,s3,s4); setcolor(1); outtextxy(100,115,"SWITCH 1"); outtextxy(220,115,"SWITCH 2"); outtextxy(340,115,"SWITCH 3"); outtextxy(460,115,"SWITCH 4"); outtextxy(115,315,"EXIT"); outtextxy(470,315,"RESET"); } void dispbutton(int n) {int x1,y1,x2,y2; if(n==1){x1=80;y1=100;x2=180;y2=140;} if(n==2){x1=200;y1=100;x2=300;y2=140;} if(n==3){x1=320;y1=100;x2=420;y2=140;} if(n==4){x1=440;y1=100;x2=540;y2=140;} if(n==5){x1=80;y1=300;x2=180;y2=340;} if(n==6){x1=440;y1=300;x2=540;y2=340;} setfillstyle(SOLID_FILL,7); bar(x1,y1,x2,y2); setcolor(15); line(x1,y1,x2,y1);line(x1,y1,x1,y2); setcolor(8); line(x2,y1,x2,y2);line(x1,y2,x2,y2); } void click(int s1,int s2,int s3,int s4) {int x1,y1,x2,y2; if(ch=='1'){x1=80;y1=100;x2=180;y2=140;} if(ch=='2'){x1=200;y1=100;x2=300;y2=140;} if(ch=='3'){x1=320;y1=100;x2=420;y2=140;} if(ch=='4'){x1=440;y1=100;x2=540;y2=140;} if(ch==27){x1=80;y1=300;x2=180;y2=340;} if(ch==32){x1=440;y1=300;x2=540;y2=340;} hidemouseptr(); setcolor(15);line(x2,y1,x2,y2);line(x1,y2,x2,y2); setcolor(8);line(x1,y1,x2,y1);line(x1,y1,x1,y2); sound(50);delay(75);nosound(); setcolor(15);line(x1,y1,x2,y1);line(x1,y1,x1,y2); setcolor(8);line(x2,y1,x2,y2);line(x1,y2,x2,y2); showmouseptr(); status(s1,s2,s3,s4); } void status(int s1,int s2,int s3,int s4) {setcolor(4);setfillstyle(SOLID_FILL,4); circle(130,200,10); circle(250,200,10); circle(370,200,10); circle(490,200,10); if(s1==1)floodfill(130,200,4); else {setcolor(0);setfillstyle(SOLID_FILL,0);circle(130,200,10); floodfill(130,200,0); setcolor(4);circle(130,200,10);setfillstyle(SOLID_FILL,4); } if(s2==1)floodfill(250,200,4); else {setcolor(0);setfillstyle(SOLID_FILL,0);circle(250,200,10); floodfill(250,200,0); setcolor(4);circle(250,200,10);setfillstyle(SOLID_FILL,4); } if(s3==1)floodfill(370,200,4); else {setcolor(0);setfillstyle(SOLID_FILL,0);circle(370,200,10); floodfill(370,200,0); setcolor(4);circle(370,200,10);setfillstyle(SOLID_FILL,4); } if(s4==1)floodfill(490,200,4); else {setcolor(0);setfillstyle(SOLID_FILL,0);circle(490,200,10); floodfill(490,200,0); setcolor(4);circle(490,200,10); } } void reset(int *s1,int *s2,int *s3,int *s4) {if(*s1==1) {outportb(port,1);delay(500);outport(port,0);} if(*s2==1) {outportb(port,2);delay(500);outport(port,0);} if(*s3==1) {outportb(port,4);delay(500);outport(port,0);} if(*s4==1) {outportb(port,8);delay(500);outport(port,0);} *s1=0;*s2=0;*s3=0;*s4=0; status(*s1,*s2,*s3,*s4); }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi ¦Õ¤ ?¤Ð Ãß??ÝÐÝ
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=1219


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review