Forum Replies Created
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
Arjun Vaghani
Participant/*simple program of file Handling*//*copy content of 1 file to another*/#include<stdio.h>main(int argc, char **argv){char ch;FILE *fp1,*fp2;if(argc!)
{printf(“Invalid syntax: use: ./cpy <source_filename> <destinatin_filename>n”);return;}fp1=fopen(argv[1],”r”);if(fp1==NULL){printf(“source file does not existsn”);return;}fclose(fp1);fp2=fopen(argv[2],”r”);if(fp2!=NULL){here: printf(“Ur file already exists..Do u want to overwrite? press y for yes and n for no:”);scanf(“%c”,&ch);if(ch==’n’||ch==’N’)return;else if(ch!=’y’&& ch!=’Y’){printf(“Invalid choicen”);goto here;}fclose(fp2);while((ch=getchar())!=’n’); /*for clearing buffer*/}fp1=fopen(argv[1],”r”);fp2=fopen(argv[2],”w”);while((ch=fgetc(fp1))!=EOF){fputc(ch,fp2);}fclose(fp1);fclose(fp2);}Arjun Vaghani
Participant/*motor.c*/
/*try this out , it’s very simple*/
/*LCD is not necessary for L293D’s interfacing with AT89S52, So i have not given, but u can add that code separately*/
/*program-start*/
#include<reg51.h>main(){while(1){unsigned char t;t=P1&0x0f; //read the data from port P1switch(t){ /*block for taking action according to input*/case 0x02:P2=0x85; /*forward*/break;case 0x04:P2=0x86; /*left*/break;case 0x06:P2=0x89; /*right*/break;case 0x08:P2=0x8A; /*backward*/break;case 0x05:P2=0x00; /*stop*/break;case 0x00:P2=0x00; /*no input*/break;}}}/*In Diagram Shown Below, by Configuring Port P1 for Different Input Combinations , U can get the Action Performed by the DC Motor, i.e Desired Motion.*/ -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)