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 / Topics / HELP NEEDED PIC16F819

HELP NEEDED PIC16F819

|

Microcontroller › PIC › HELP NEEDED PIC16F819

  • This topic has 1 reply, 2 voices, and was last updated 7 years, 3 months ago by djouadi.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • January 31, 2019 at 9:10 am #5001
    Gabrielle DesireƩ
    Participant

    I'm a newbie to this site, so please excuse me if I'm posting in the wrong forum section, or if my question is too elementary. I've just recently started using MPLab to program a PIC16F819 I'm trying to write a code in which a single LED is switch on if 2 certain switches are pressed within 2 seconds of each other. I've started a basic code in which I have 4 inputs (switches) and four outputs (LED's) at the moment each switch corresponds to a single LED so if I was to press switch1 then LED1 lights up.

    How would I code the PIC so that LED1 would light up if I was to press switch1 and then switch2 (within 3 seconds of each other)?

    Thanks in advance.

     

    Current code:

     

    #include <16F819.h> 

    #fuses INTRC_IO,NOWDT,NOPROTECT,MCLR,NOBROWNOUT

    #use delay(clock=4000000) 

     

    #define SW2 PIN_B7

    #define SW2 PIN_B6

    #define SW3 PIN_B5 

    #define SW4 PIN_B4 

    #define LED1 PIN_B3

    #define LED2 PIN_B2

    #define LED3 PIN_B1

    #define LED4 PIN_B0

     

    void main()

    { 

    port_b_pullups(TRUE); 

     

    while(1)

      { 

    if(!input(SW1)) output_high(LED1); 

    if(!input(SW2)) output_high(LED2); 

    if(!input(SW3)) output_high(LED3); 

    if(!input(SW4)) output_high(LED4); 

     

      } 

    }

     

    February 11, 2019 at 8:17 am #15017
    djouadi
    Participant

    This will involve use of timer and external interrupts…i appreciate your creativity…but you need to keep this spin off task in pipeline till you are done with timers, interrupts and other basic features of the PIC

  • 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

  • Phone Charger 5v to 12v May 17, 2026
  • reviving old swordfish program but? May 17, 2026
  • Assistance locating a 'trail' camera gadget, please ? May 16, 2026
  • Analog multiplexer has gone obselete May 16, 2026
  • Difference between TTL, RS232 and RS485 May 16, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

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