Hi there! Here is my code:
I am trying to send b'10000' to portA only if bit 0 on PORTB is 1. Basically make the LED lit when I press a button. I use the PIC simulator but also when testing in circuit, it doesn't work. I ground (w/ 10k resistor PORTB,0). Please explain what I am doing wrong! Thanks!!!!
Code:
title "Program"
include "p16f84a.inc"
;===== variables ===========
count1 equ 0xc
count2 equ 0xd
;===== end variables =======
;===== set ports ======
bsf STATUS,RP0 ;set PORTB, 0 to input, others to output
movlw 0x1
movwf TRISB
movlw 0x0
movwf TRISA
bcf STATUS, RP0
; ====== end ======
movlw b'10000'
start:
BTFSC PORTB,0 ; exectute next instruction if PORTB,0 is 1.
movwf PORTA
goto start
end
I am trying to send b'10000' to portA only if bit 0 on PORTB is 1. Basically make the LED lit when I press a button. I use the PIC simulator but also when testing in circuit, it doesn't work. I ground (w/ 10k resistor PORTB,0). Please explain what I am doing wrong! Thanks!!!!