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 :1000080009005620642083160