EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home

Arjun Vaghani

  • Profile
  • Topics Started
  • Replies Created
  • Engagements

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 25, 2013 at 7:01 am in reply to: Programs related to file handling in C language. #9370
    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!=3)
     {
       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);
    }
     

     

    March 25, 2013 at 6:25 am in reply to: L293D interfacing with 8051 #9369
    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 P1
    switch(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.*/

     

    wysiwyg_imageupload:7864:

     

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)

RSS Recent Posts

  • IoT: Transforming Businesses with Digital Engineering June 23, 2025
  • PIC KIT 3 not able to program dsPIC June 23, 2025
  • Fun with AI and swordfish basic June 23, 2025
  • Is AI making embedded software developers more productive? June 23, 2025
  • Microinverters and storeage batteries? June 22, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise