Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

HOME AUTOMATION SYSTEM :

Code :
#include <p18f4520.inc>

;LIST P=PIC18F4520, F=INHX32, N=0, ST=OFF, R=HEX

;config OSC=HS, OSCS=OFF, WDT=OFF, BORV=45, PWRT=ON, BOR=ON, DEBUG=OFF, LVP=OFF, STVR=OFF

;Inputs

TEMP EQU RB0

MOTION EQU RB1

DOOR EQU RB2

SENSOR EQU PORTB

;Ouputs

; FanOUT RC0

; LEDMOTION RC1

; LEDDOOR RC2

ORG 00H

main

MOVLW 0FH

MOVWF ADCON1

MOVLW 07H ;0000 0111

MOVWF TRISB
TempSensing

BTFSS SENSOR,TEMP

GOTO TempLow

BSF PORTB,3 ; Turn on the fan

GOTO MotionSensing

TempLow

BCF PORTB,3 ; Turn off the fan

MotionSensing

BTFSS SENSOR,MOTION

GOTO Undetected

BSF PORTB,4 ; Turn on the LED motion

GOTO DoorSensing

Undetected

BCF PORTB,4 ; Turn off the LED MOTION

DoorSensing

BTFSS SENSOR,DOOR

GOTO DoorClose

BSF PORTB,5 ; Turn on the LED for Door

GOTO TempSensing

DoorClose

BCF PORTB,5 ; Turn off the LED for Door

GOTO TempSensing

END

Simulations
Start
Flow Chart

Read Temperature
Sensor

Control
Thermostat

Read Motion and


Door Sensor

Control
lighting

Delay

Loop

End
Block diagram : Temperature Sensor

ADC Converter

Microcontroller
PIC18F4520

Motion Sensor

Door Sensor

Smart Thermostat
Control

Smart Lighting
Control

You might also like