Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
;Author : Leprechaun
;Date: September 23rd 2009
;PROGRAM FUNCTION:light control for smart home
list P=16F877a
include "P16F877a.inc"
__config 0x3D18
;***Declarations***
CBLOCK 20h
NumH
NumL
ENDC
;***
ORG 0x000
GOTO Init
ORG 0x004
Init
CLRF PORTA ; Initialize PORTA by
BSF STATUS, RP0 ; Select Bank 1
MOVLW 0x06 ; Configure all pins
MOVWF ADCON1 ; as digital inputs
MOVLW 0xCF ; Value used to initialize data direction
MOVWF TRISA ; Set RA<3:0> as inputs RA<5:4> as outputs TRISA<7:6>are always read as '0'.
MOVLW b'10000101' ;
MOVWF ADCON1 ;
BCF STATUS,RP0 ;
MOVLW b'10000001' ;
MOVWF ADCON0 ;
;Program Start:
Main
; Read_ADC
BSF ADCON0, GO_DONE ;initiate conversion
BTFSC ADCON0, GO_DONE
GOTO $-1 ;wait for ADC to finish
MOVF ADRESH,W
MOVWF NumH
BSF STATUS,RP0
MOVF ADRESL,W
MOVWF NumL ;return result in NumL and NumH
BCF STATUS,RP0
BTFSS NumH,1
GOTO led_on
BCF PORTA,4 ; turn 0ff the LED
GOTO Main
led_on
BSF PORTA,4 ;turn on the LED
GOTO Main
END
;PROGRAM FUNCTION:light control for smart home
;Written by: : Lebohang Maphothoane
list P=16F877a
include "P16F877a.inc"
__config 0x3D18
;errorlevel -302, -207;suppress message 302 from the list
;Declarations:
NumH equ 20h
NumL equ 21h
org 0x0000
goto Start
;Program Start:
Start
call Init ;sets the values of ADCON0 and ADCON1
;initialize porta
Main
; Read_ADC
bsf ADCON0, GO_DONE ;initiate conversion
btfsc ADCON0, GO_DONE
goto $-1 ;wait for ADC to finish
movf ADRESH,W
andlw 0x03
movwf NumH
BANKSEL ADRESL
movf ADRESL,W
BANKSEL ADRESH
movwf NumL ;return result in NumL and NumH
btfss NumH,1
goto led_on
bcf PORTA,4 ; turn 0ff the LED
goto Main
led_on
bsf PORTA,4 ;turn on the LED
goto Main
;Subroutines:
; initialize ADC
Init
; Initializing porta
BCF STATUS, RP0 ;
BCF STATUS, RP1 ; Bank0
CLRF PORTA ; Initialize PORTA by
; clearing output
; data latches
BSF STATUS, RP0 ; Select Bank 1
MOVLW 0x06 ; Configure all pinss
MOVWF ADCON1 ; as digital inputs
MOVLW 0xCF ; Value used to
; initialize data
; direction
MOVWF TRISA ; Set RA<3:0> as inputs
; RA<5:4> as outputs
; TRISA<7:6>are always
; read as '0'.
movlw b'10000001';
movwf ADCON0 ;
BANKSEL ADCON1
movlw b'10000101'
movwf ADCON1
BANKSEL ADCON0
return
END
What is a "bid cock electric"