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