SOURCE CODE:
/* PROGRAM TO CONTROL MULTIPLE DEVICES USING PC’S PARALLEL PORT */
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
#include<string.h>
FILE *status;
int ch;
char *dev_list[]={“idle”,”TUBELIGHT”,”FAN”,”NIGHTLAMP”,”TELEVISION”, ”AIRCOOLER”,”REFRIGERATOR”,”DVD_PLAYER”,”end” };
int day[]={0,2,4,6,0,1,3,5,7,0};
int night[]={0,1,2,3,5,6,7,0,4,0};
int out[]={0,3,0,1,2,4,5,6,7,0};
int reset[]={0,0,1,2,3,4,5,6,7,0};
int device[256];
int port=0×378;
void activate(int *ptr);
void switch_load(int);
main()
{
int disp_menu();
void disp_load();
void profiles();
void switching();
void load_status();
void exit_code();
int welcome();
int choice;
int hour;
status_file();
for(;;)
{
clrscr();
hour=welcome();
choice=disp_menu();
switch(choice)
{
case 1: disp_load();
printf(“nnn Press any key to continue….”);
getch();
break;
case 2: profiles();
break;
case 3: switching();
break;
case 4: load_status();
break;
case 5: exit_code(hour);
default: printf(“nn INVALID CHOICE”);
printf(“nnnnn PRESS ANY KEY TO RETURN TO MAIN MENU…..”);
getch();
}
}
}
status_file()
{
int i=0;
status=fopen(“status.txt”,”r”);
if(status==NULL)
{
puts(“Unable to open device status file”);
exit(1);
}
while(1)
{
ch=fgetc(status);
if(i>=256)
break;
else
device[i]=ch;
i++;
}
fclose(status);
return(0);
}
welcome()
{
struct time t;
struct date d;
clrscr();
printf(“nnttt $$$ POWER CONTROL USING PC $$$nnn”);
gettime(&t);
getdate(&d);
printf(“nn TIME: %2d:%2d”,t.ti_hour,t.ti_min);
printf(“nn DATE: %2d/0%d/%2d”,d.da_day,d.da_mon,d.da_year);
if(t.ti_hour>=0×5&&t.ti_hour<0xb)
printf(“nn GOOD MORNING….n”);
if(t.ti_hour>=0xb&&t.ti_hour<0×11)
printf(“nn GOOD AFTERNOON….”);
if(t.ti_hour>=0×11&&t.ti_hour<0×16)
printf(“nn GOOD EVENING….”);
return(t.ti_hour);
}
int disp_menu()
{
int choice;
printf(“n 1.LIST OF LOADS & THEIR CODES”);
printf(“n 2.STANDARD PROFILES(DAY/NIGHT)”);
printf(“n 3.SWITCHING”);
printf(“n 4.LOAD’S STATUS”);
printf(“n 5.EXITn”);
printf(“tttt ENTER YOUR CHOICE:”);
scanf(“%d”,&choice);
return(choice);
}
void disp_load()
{
int i;
clrscr();
printf(“n THE LIST OF LOADS WHICH CAN BE CONTROLLED ARE:nn”);
for(i=1;strcmpi(&dev_list[i][0],”end”);i++)
printf(“nt %2d.%s”,i,dev_list[i]);
return;
}
void profiles()
{
char p;
for(;;)
{
clrscr();
printf(“n STANDARD PROFILES:n”);
printf(“nntt 1.DAY MODE”);
printf(“ntt 2.NIGHT MODE”);
printf(“ntt 3.OUT OF STATION”);
printf(“ntt 4.RESET”);
printf(“ntt 5.EXIT”);
printf(“nnnn ENTER YOUR CHOICE: “);
p=getchar();
switch(p)
{
case ‘d’:
case ‘D’:
case ’1′: activate(day);
return;
case ‘n’:
case ‘N’:
case ’2′: activate(night);
return;
case ‘o’:
case ‘O’:
case ’3′: activate(out);
return;
case ‘r’:
case ‘R’:
case ’4′: activate(reset);
return;
case ‘e’:
case ‘E’:
case ’5′: return;
}
}
}
void activate(int *ptr)
{
int i;
char c;
printf(“nnTHE FOLLOWING DEVICES WILL BE SWITCHED ON…..n”);
for(i=1;ptr[i]!=0;i++)
printf(“n%d.%s”,ptr[i],dev_list[ptr[i]]);
printf(“nnTHE FOLLOWING DEVICES WILL BE SWITCHED OFF…..n”);
for(i++;ptr[i]!=0;i++)
printf(“n%d.%s”,ptr[i],dev_list[ptr[i]]);
printf(“nn DO YOU WANT TO ACTIVATE THIS PROFILE….(y/n):”);
c=getch();
printf(“%c”,c);
getch();
if(c==’y'||c==’Y')
{
for(i=1;ptr[i]!=0;i++)
if(device[ptr[i]]==0)
switch_load(ptr[i]);
for(i++;ptr[i]!=0;i++)
if(device[ptr[i]]==1)
switch_load(ptr[i]);
}
}
void switching()
{
int i,on_off;
disp_load();
printf(“nnnnEnter the code of the device to be switched:”);
scanf(“%d”,&i);
printf(“OPTIONS:”);
printf(“t 0–OFFt 1–ONn”);
printf(“n ENTER YOUR CHOICE:”);
reenter: scanf(“%d”,&on_off) ;
if(on_off==1)
{
if(device[i]==1)
{
printf(“nThe Device is already ON”);
getch();
}
else
switch_load(i);
}
else if(on_off==0)
{
if(device[i]==0)
{
printf(“nThe Device is already OFF…”);
getch();
}
else
switch_load(i);
}
else
{
printf(“Invalid optionn Please Re-enter”);
goto reenter;
}
}
void load_status()
{
int i;
clrscr();
printf(“nn THE FOLLOWING DEVICES ARE ON:n”);
for(i=1;strcmpi(&dev_list[i][0],”end”);i++)
if(device[i]==1)
printf(“n%d.%s”,i,dev_list[i]);
printf(“nnTHE FOLLOWING DEVICES ARE OFF:n”);
for(i=1;strcmpi(&dev_list[i][0],”end”);i++)
if(device[i]==0)
printf(“n%d.%s”,i,dev_list[i]);
printf(“nnnnPress any key to continue……”);
getch();
}
void switch_load(int adrr)
{
if(device[adrr]==0)
{
device[adrr]=1;
outportb(port,adrr);
delay(50);
outportb(port,0×00);
}
else
{
evice[adrr]=0;
outportb(port,adrr);
delay(50);
outportb(port,0×00);
}
}
void exit_code(int hour)
{
clrscr();
printf(“ttt THANK YOU FOR USING THIS SOFTWARE n”);
if(hour>=0×13||hour<=0×4)
printf(“nn GOOD NIGHT….n”);
file_update();
printf(“nnnnnnn Press any key to EXIT……”);
getch();
exit(0);
}
file_update()
{
int i=0;
status=fopen(“status.txt”,”w+”);
if(status==NULL)
{
puts(“Unable to open device status file”);
exit(1);
}
while(1)
{
ch=device[i];
if(i>=256)
break;
else
fputc(ch,status);
i++;
}
fclose(status);
return 0;
}
CONCLUSION:
This project, can be effectively and conveniently utilized for the control of different appliances. As this project could be extended to control about 255 devices, this could be used for computerization of an office, home, or a firm. Though it is quiet costlier, the circuit is simple and the working mechanism could be easily understood. An added advantage of this project is that we are able to know the status of the device to be controlled. The program to control the appliances is written in C language which is more user friendly and easy to understand than other programming languages.
Disadvantages / Improvements:-
If at all a new device has to be added to the hardware the software doesn’t support this to achieve which the source code has to be changed manually.
The status of all the devices that are switched are maintained in a database which may not coincide with actual status of the devices as we are not reading the status directly from the HARDWARE.
By
1. Anand Kumar. N. Ilkal
2. Anil Kumar Desai
3. Gara Naveen
4. Umesh. N. Sajjan
Description :
This is the one stop educational site for all Electronic and Computer students. If you want to learn something new then we are here to help. We work on Microcontroller projects, Basic Electronics, Digital electronics, Computer projects and also in basic c/c++ programs.
#Home #Sitemap #Submit #Terms of Use
Copyright©2011 electrofriends.com All Rights Reserved
Contact:info@electrofriends.com | Powered by Dhyeya
[...] he encontrado esta otra sobre el mismo [...]
i want to know the method of switching using microcontrollers
PLEASE SAND ME SOURCE CODE OF CONTROLING POWER BY PC IN JAVA LANGUAGE……….
it can control device, can it be used to montior voltage and some I/O signal and the same time?
is there RS232 VERSION instead of parallel port?
thank you
i want to download the schematic diagram of device switching using pc’s parallel port
hi.. i want to download the source code of device switching using pc’s parallel port in c#.net sp please forward it to my email-id its urgent require so please please send code to me
I have tried the program but it does not give the desired outpt though it prints what you have showed in your screen shots..Kindly help us as it is related to the filnal year project..Please !!!!
We have taken this project & got selected but now there is a problem…………
I have tried to make the artwork & layout but it does not succeded.
Kindly help us as it is related to the third year project as soos as possible..Please send the same on my e-mail id OR give us direction!!!!
Please help us >>>>>> to download the schematic diagram of device switching using pc’s parallel port.
we have to submit our project upto end of this month… PLEASE HURRY & HELP US….
I would like to build the circuit and test it. Can you please send me the source code. I also do not have a turbo compiler.
Regards,
Iqbal
i want to do the project which is control of electrical appliance such asaaaaaa
a bulb but i have problem with the programmation how can i sort it?
i find it difficult to locate pin no. of ic74ls93,74ls75 , 74f139, can you help/
though i liked the project & wanted to go through the entire project but i could not see the last part of the project..every time i clicked on the page links..only the 1st page is getting re-opened..plzz help…i need it…if possible plzzz send me a copy of the entire project in my email-id
i have this project circuit diagram,coding,pcb,all components and a
hard copy of this project.contact jai.mishra@ymail.com
PLEASE SAND ME SOURCE CODE OF CONTROLING POWER BY PC IN JAVA LANGUAGE
hi,i am thirumalai from tamilnadu.now i am studing in final year ece department.i want ideas from multiple device switching through parallel port in wireless controll using virtual basic software, so please guide to me…………………….
I am a final year ECE student and i am going to work in pc based wireless appliance controller.So please send me the source code in Visual basic or c language.
[...] Device Switching Using PC’s Parallel Port [...]
i want circuit diagram of thi project……. please send me
i like to make a project on switching device using parallel port in c. i had copied the source file but what is the status file. please reply me fast. i have to submit it tomorrow. please help