Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Light control system for smart home

Status
Not open for further replies.
Mike

On my screen the post looks fine - how far out is it?

R
 
Hum...I also use firefox and it's spot on, I will do a PDF instead
 
Mike,

This should be OK now, thanks :D
 
Thanks guys, hear is the code i have corrected. it does not have errors, i tested it on MPLAB IDE v8.5. But it has warnings and masseges,i tried to get rid of those warnings but i could not. can u guys show me why there is those warnings and how should i get rid off them.



;PROGRAM FUNCTION:light control for smart home

list P=16F877a

include "P16F877a.inc"
__config 0x3D18
;Declarations:


NumH equ 20h
NumL equ 21h
org 0x0000


; 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'.


return


;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 movlw b'10000001';
movwf ADCON0 ;
BANKSEL ADCON1
movlw b'10000101'
movwf ADCON1
BANKSEL ADCON0

return


END
 
birdman0 o i still remember how you said i should paste the code, i tried to paste it like that but i could see how to do it. iam sorry for that.
 
Nvm, did it fast, and it compiled!


Code:
;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
 
HI Birdman 0 i have been off for 5 days. im glad to see that code you have paste. i have tested it on MPLAB and i was happy with the results. below is my code which i tried to correct it before i got that one.

Code:
;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
 
hello birdman0, the project is not yet finished that was part one. The second part is that i have to use the motion sensor to detect movement. and the system should work like this: if there is movement then the LEDs must be on and if there is no movement, the LEDs must be off
 
The motion sensor iam to use is called PIR325 Infrared Pyroelectric Sensor. i do not know how it operates, i searched and read about it but i do not get exactly what i want. i want to know whether there is output voltage i can read from the sensor if the sensor detects any moving object and how much is the output voltage if there is no movement.
 
please,can u help me?i have a problem to sensor pir.i use sensor pir to receive signal to turn on_off bid cock electric.i don't understand this law.can u help me?if u can give me application circuit,it is useful for me
 
Part three of the project is to use the stepping motor. im going to use the unipolar stepping motor to close or open the blinds(curtain window) depending on the light needed. i have to open the blinds using the motor, i have to turn the motor to a certain angle depending on how i want to open the blinds.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top