#include #include #include int maxx,maxy,x,y,button,bulb1=2,bulb2=2,bulb3=2,bulb4=2; int style=SOLID_FILL,size=5,ang=0,ang1=0,ang2=0,ang3=0; int fb1=120,fb2=248; void main(void) { int gdriver = DETECT,gmode,errorcode; initgraph(&gdriver,&gmode, "d:\\turboc3"); settextstyle(SMALL_FONT,HORIZ_DIR,size); /*to set a text style*/ setcolor(3); rectangle(0,56,getmaxx(),getmaxy()); /*control panel rectangle*/ rectangle(0,0,getmaxx(),50); /*rectangle for aim*/ line(1,82,getmaxx()-1,82); /*line under heading*/ setviewport(1,57,getmaxx()-1,getmaxy()-1,1); gotoxy(26,2); printf("ELECTRICAL EQIPMENT CONTROL USING PC"); /*aim of project*/ style=SOLID_FILL; gotoxy(32,5); printf("CONTROL PANEL"); outportb(0x378,0); /*making initialy all bulbs off*/ if(initmouse()==0) { closegraph(); restorecrtmode(); printf("Mouse Driver not loaded\n"); exit(1); } restrictmouseptr(1,57,getmaxx()-1,getmaxy()-1); showmouseptr(); equip(170,100,10,15,0); /*for bulb1*/ equipbase(164,110,176,120); equip(95,85,10,35,0); /*for tube*/ equipbase(85,110,105,120); equipbase(85,50,105,60); setcolor(14); circle(28,85,25); /*for fan*/ circle(28,85,5); sector(28,85,75,105,25,25); sector(28,85,210,240,25,25); sector(28,85,300,330,25,25); equipbase(25,110,28,115); equipbase(18,115,35,120); equip(238,100,10,15,0); /*for bulb2*/ equipbase(232,110,244,120); equip(320,100,10,15,0); /*for feedback*/ equipbase(314,110,326,120); cleartext(0,180,637,365,3); /*lower box */ putbuttons(); /*put all the buttons*/ while(1) { getmousepos(&button,&x,&y); gotoxy(65,2); printf("X=%d\tY=%d\n",x,y); checkstat(); if(bulb1%2==1) { equip(28,85,25,25,0); /*for fan*/ equip(28,85,5,5,0); setfillstyle(style,14); sector(28,85,ang1+30,ang1+60,25,25); sector(28,85,ang2+120,ang2+150,25,25); sector(28,85,ang3+255,ang3+285,25,25); equip(28,85,25,25,0); /*for fan*/ equip(28,85,5,5,0); ang1=ang1+20; ang2=ang2+20; ang3=ang3+20; } } getch(); closegraph(); } /*method for checking status of mouse click*/ checkstat() { int button,x,y,a,res; getmousepos(&button,&x,&y); /*for exit*/ if( (button & 1)==1 && x>=550 && x<=630 && y<=457 && y>=433) { delay(300); exit(1); } /*for fan*/ if( (button & 1)==1 && x>=6 && x<=68 && y<=213 && y>=176) { res=inportb(0x378); res=res^1; outportb(0x378,res); /* moveto(20,30);*/ /* printf("signal=%d from computer",res);*/ res=res&1; if(bulb1%2==0 && res==1) { cleartext(5,125,70,155,6); setcolor(10); outtextxy(15,129,"FAN ON"); fb1=248; /*for on signal*/ fb2=120; /*for off signal*/ } if(bulb1%2!=0 && res==0) { cleartext(5,125,70,155,6); setcolor(10); outtextxy(15,129,"FAN OFF"); equip(28,85,25,25,0); /*for fan*/ equip(28,85,5,5,0); setfillstyle(style,14); sector(28,85,ang1+75,ang1+105,25,25); sector(28,85,ang2+210,ang2+240,25,25); sector(28,85,ang3+300,ang3+330,25,25); fb1=120; /* for on signal*/ fb2=248; /*for off signal*/ } bulb1++; delay(300); } /*for tube*/ if( (button & 1)==1 && x>=75 && x<=125 && y<=213 && y>=176) { res=inportb(0x378); res=res^2; outportb(0x378,res); /*moveto(20,30);*/ /*printf("signal=%d from computer",res);*/ res=res&2; if((bulb2%2==0) && (res==2)) { equip(95,85,10,35,15); equipbase(85,110,105,120); equipbase(85,50,105,60); } if(bulb2%2!=0 && res==0) { equip(95,85,10,35,0); equipbase(85,110,105,120); equipbase(85,50,105,60); } bulb2++; delay(300); } /*for bulb1*/ if( (button & 1)==1 && x>=145 && x<=206 && y<=213 && y>=176) { res=inportb(0x378); res=res^4; outportb(0x378,res); /*moveto(20,30);*/ /*printf("signal=%d from computer",res);*/ res=res&4; if(bulb3%2==0 && res==4)equip(170,100,10,15,14); if(bulb3%2!=0 && res==0)equip(170,100,10,15,0); bulb3++; delay(300); } /*for bulb2*/ if( (button & 1)==1 && x>=215 && x<=260 && y<=213 && y>=176) { res=inportb(0x378); res=res^8; outportb(0x378,res); /*moveto(20,30);*/ /*printf("signal=%d from computer",res);*/ res=res&8; if(bulb4%2==0 && res==8)equip(238,100,10,15,14); if(bulb4%2!=0 && res==0)equip(238,100,10,15,0); bulb4++; delay(300); } /*for feedback*/ if( (button & 1)==1 && x>=285 && x<=360 && y<=213 && y>=176) { a=inportb(0x379); moveto(20,30); printf("signal=%d from computer",a); if(a==fb1)equip(320,100,10,15,14); if(a==fb2)equip(320,100,10,15,0); delay(300); } /*for info*/ if( (button & 1)==1 && x>=26 && x<=76 && y<=457 && y>=431) { cleartext(0,180,637,365,3); setcolor(14); settextstyle(TRIPLEX_FONT,HORIZ_DIR,1); /*to set a text syle*/ outtextxy(55,190,"MINIPROJECT ELECTRICAL EQUIPMENT CONTROL USING PC"); outtextxy(60,215,"* This software is completely designed by our group."); outtextxy(60,240,"* GROUP-SAMEER,PARAS & MURTAZA."); outtextxy(60,265,"*If any more info required contact on 4213727."); delay(300); settextstyle(SMALL_FONT,HORIZ_DIR,size); /*to set a text syle*/ } /*for help*/ if( (button & 1)==1 && x>=126 && x<=176 && y<=456 && y>=432) { cleartext(0,180,637,365,3); setcolor(14); settextstyle(TRIPLEX_FONT,HORIZ_DIR,1); /*to set a text syle*/ outtextxy(55,190,"HELP"); outtextxy(60,215,"* Click on BULB1/BULB2 for making bulbs ON/OFF"); outtextxy(60,240,"* Click on tube to make tube on"); outtextxy(60,265,"* Click on FAN OFF to make fan ON"); outtextxy(60,290,"* Clear button clears the text in lower window"); delay(300); settextstyle(SMALL_FONT,HORIZ_DIR,size); /*to set a text syle*/ } /*for clear*/ if( (button & 1)==1 && x>=226 && x<=276 && y<=456 && y>=432) cleartext(0,180,637,365,3); return 0; } /*method for putting buttons*/ putbuttons() { setcolor(3); line(0,180,640,180); /*for dividing screen in two parts*/ setcolor(6); rectangle(25,400,75,375); /*for info */ rectangle(125,400,175,375); /*for clear*/ rectangle(225,400,275,375); /*for help*/ rectangle(550,375,630,400); /* for exit*/ rectangle(5,125,70,155); /*for fan */ rectangle(80,125,125,155); /*for tube*/ rectangle(145,125,187,155); /*for bulb1*/ rectangle(215,125,260,155); /*for bulb2*/ rectangle(285,125,360,155); /*for feedback*/ setcolor(10); outtextxy(11,129,"FAN OFF"); outtextxy(85,129,"TUBE"); outtextxy(150,129,"BULB1"); outtextxy(220,129,"BULB2"); outtextxy(30,374,"INFO"); outtextxy(130,374,"HELP"); outtextxy(230,374,"CLEAR"); outtextxy(570,374,"EXIT"); outtextxy(290,129,"FEEDBACK"); return 0; } /* method for drawing circles in equipment*/ equip(int x1,int y1,int a1,int b1,int c) { setcolor(14); setfillstyle(style,c); fillellipse(x1,y1,a1,b1); } /* method for equipment base*/ equipbase(int x2,int y2,int a2,int b2) { setcolor(8); setfillstyle(SOLID_FILL,8); bar3d(x2,y2,a2,b2,0,0); } /*method for clearing text*/ cleartext(x3,y3,a3,b3,c1) { setcolor(c1); setfillstyle(style,0); bar3d(x3,y3,a3,b3,0,0); }