automatic staircase lighting using pic16f676 and sr04 ultrasonic sensor
PROGRAM
#chip 16F676,0
#config MCLRE=OFF
;Include files (Libraries)
#include <srf04.h>
dir PORTc.2 out
dir portc.4 out
dir portc.3 out
#define US1Ping PORTc.0
#define US1Echo PORTc.1
#define checkdistance 50
Dim detect as word
set portc.2 on
wait 1 s
set portc.2 off
Do
set portc.4 on
wait 50 ms
set portc.4 off
wait 50 ms
set portc.4 on
wait 50 ms
set portc.4 off
wait 500 ms
match = USDistance(1)
if match < checkDistance then
Set PORTc.2 On
wait 10 s
Set PORTc.2 Off
Else
Set PORTc.2 Off
end if
Loop
HEX CODE
HOW TO HEX USE HEX CODE
COPY THE CODE BELOW TO ANY IDE AND SAVE THIS WITH EXTENSION AS .HEX.THATS IT.DOWNLOAD THIS .HEX FILE DIRECTLY TO IC
:020000040000FA
:020000000528D1
:1000080009005620642083160711071287118312EE
:1000180007150130A4004E20071107163230A20040
:10002800A301402007123230A200A3014020071686
:100038003230A200A30140200712F430A2000130A0
:10004800A30040200130AD0074202B08A7003230F7
:1000580027020318352807150A30A4004E20071177
:10006800362807111128630037280230A000A00B9A
:100078003B28A50B39280800A30A8E30A1000130BF
:10008800A000A00B4528A10B4328A20B4128A30BD5
:1000980041280800E830A2000330A3004020A40B48
:1000A8004E280800FF238316900083129F131F1009
:1000B8008316910107308312990085018701080092
:1000C80083160710871483120800A0012508290247
:1000D800031D080026082A02031D0800A0090800BD
:1000E800AB01AC0107140130A50039200710871CAB
:1000F8007B28871C9028AB0A0319AC0A2B08A5009B
:100108002C08A600A901AA016920201808001130AE
:0A011800A000A00B8D287D28080030
:02400E00D43F9D
:00000001FF
Comments
Post a Comment