Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Reading two switches at a time from pic16f877a

Status
Not open for further replies.
By using a digital input, no way.

By using an analog input, you can do that with an unbalanced resistive net.
This way:

Code:
    Vcc
      |
      |
      |
     ---
    |   |
    |   |R1
    |   |
     ---	
      |
      |-------- Analog Input
      |
  ---------
  |       |
 ---     ---
|   |   |   |
|   |R2 |   |R3
|   |   |   |
 ---     ---
  |       |
  |       |
  |       |
   \ Sw1    |- Button
  |       |
  |       |
  |       |
-----   -----
 ---     ---
  -       -

I'm assuming that you want to read both at the same pin.
 
If they are connected to the same port, read the port (rather than the 2 bits)
 
You can also use this if two pins are used.

Code:
TRISB1 = 1;
TRISB2 = 1;
if( (RB1>0) && (RB2>0) ) {
//do something
}

Reed switch is also a normal switch with digital output open or close, but operated with help of magnet, you can also use Interrupts if required,
 
Hi,
You can enable the interrupts for the both the pins, when ever change occurred it automatically capture that information.

If that pins are connected to the single port, you can read that port & could perform some bit wise operation to get the result.
 

Thanks boy. But i have to sense it on separate pins
but thanks alot

- - - Updated - - -

Hi,
You can enable the interrupts for the both the pins, when ever change occurred it automatically capture that information.

If that pins are connected to the single port, you can read that port & could perform some bit wise operation to get the result.

thank you very much
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top