Jump to content
tiagopirassol

codigo acender led

Recommended Posts

tiagopirassol
#include <p16f887.inc>
; CONFIG1
__CONFIG _CONFIG1, _FOSC_INTRC_NOCLKOUT & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_ON & _IESO_ON & _FCMEN_OFF & _LVP_OFF
; CONFIG2
__CONFIG _CONFIG2, _BOR4V_BOR40V & _WRT_OFF
org 0x0000 ; endereço de reset
goto main
configs:
 bsf	 STATUS, RP0; activa banco 3
 bsf	 STATUS, RP1
 clrf ANSEL
 clrf ANSELH
 bsf	 STATUS, RP0; activa banco 1
 bcf	 STATUS, RP1
 bsf	 TRISA, RA0 ; Definir entradas S1
 bcf	 TRISD, RD0 ; Definir saidas LED
 bcf	 STATUS, RP0; activa banco 0
 bcf	 STATUS, RP1
 bcf	 PORTD, RD0; desligar LED
 return

controlar:
liga:
 btfsc PORTA, RA0; quando bit for zero salta instrução, senão repete
 goto liga
 bsf	 PORTD, RD0; LIGAR led
desliga:
 btfss PORTA, RA0; quando o nit for um slata instrução, senão repete
 goto desliga
 bcf	 PORTD, RD0; Desliga Led
 return
main: call configs; chama configurações que permitem funcionar o programa
 call controlar; executa o programa
 goto main; reinicia o processo
Fim:
 end

Share this post


Link to post
Share on other sites
KawaiiCreeper

Isso é funcional ou tens algum problema no código?

Edited by KawaiiCreeper

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.