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
You are here: Home / Topics / whats wrong with my coding?

whats wrong with my coding?

|

Electronics › Electronics › whats wrong with my coding?

  • This topic has 1 reply, 2 voices, and was last updated 11 years ago by i_engineer.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • June 9, 2011 at 10:32 am #991
    thanikai
    Participant

    below is my coding, where i used to ON and OFF 2 LEDs using 2 push button… the conditions were as below:-

    – when push button 1 presed, LED 1 ON after 2.5 sec and followed by LED 2 ON after another 2.5 sec.

    – when push button 2 presed LED 2 OFF after 2.5 sec and followed by LED 1 OFF after another 2,5 sec…

     

    when i simulate using proteus, there was no found problem and it function as the condition above.. but when i applied it through hardware, the LEDs ON and OFF automatically without press push button..

     

    pls any1 help me to identify which part of my coding hs problem.. 10q

     

    #include <htc.h>
    #include <pic.h>
    //#include <delay.h>

    #define _XTAL_FREQ 20000000
    int count = 0;

    void main()
    {
    TRISA = 0x11100000; // RA0 to RA2 as input, rest as output
    TRISB = 0x00000000; // port B output
    PORTB = 0x00; //clear portB

    while (1)
     
     
     {

     if (RA0 == 1)
      {
       __delay_ms(1000);  //delay 2.5 s

       RB4 = 1;   //LED on
       __delay_ms(1000);  //delay 2.5 s

       RB5 = 1;   //Relay on
       count = 1;
       
      }

     if (RA1 == 1)
      {
       __delay_ms(1000);  //delay 2.5 s

       RB5 = 0;   //Relay off
       __delay_ms(1000);  //delay 2.5 s

       RB4 = 0;    //LED off
       count = 2;
      }
     }
    } 

     

    August 7, 2011 at 12:49 pm #6590
    i_engineer
    Participant

    Hi !

     

    Can you post here your schematic

     

    so, i can help you.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Nokia 5110 HW in Oshonsoft August 17, 2022
  • Digital Display Information August 17, 2022
  • Seeking Help to compile code August 17, 2022
  • 2nd pcb design program? August 17, 2022
  • Door exit button August 17, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 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