Pic 18F452 / push button

microcontrollermplabpic

I want to write program with " MPLAB IDE v8.50>>Pic18f452 " by 1) low level pulse & 2)Rising edge . but, how?(without interupt & micro C,maybe!)
I wrote this program with falling edge.
Thanks a lot.

enter image description here
enter image description here

This is my circuit in proteus 7.7 .

enter image description here

Best Answer

  1. You must use below circuit.
  2. Define RB0 as input (TRISB = 1).
  3. Enable RB0 interrupt (INTCON = 0b10010000).
  4. Put your code on interrupt subroutine.

enter image description here

Here's a sample code writing in mikroC for PIC:

void interrupt(void)
{
  if (INTCON.INTF)
  {
    // your code
    INTCON.INTF = 0;
  }
}

void main()
{
  TRISB = 0b00000001;
  INTCON = 0b10010000; 
  while (1) ;
}