Electronics BH
Newbie level 3

hi ,
I want o write a code for a distance meter using Mikroc Pro , using ultrasonic sensor ( HC-SR04 ) , pic16f628a , and 16 *2 LCD .
What i understand about this sensor module is the following :
in the code :
1 - you have to end a trigger signal ( 5 V) .
2- delay_us(15),
3- set the trigger pin to be low ( 0 V) again , then the module will send a burst signal ( 40 Khz) .
3- after sending the signal, the ECHO pin will be high ( 5 v) automatically , so in the code we have to wait for this pin to be high .
4- when ECHO pin becomes high (5V) , we have to start the timer .and listening to the ECHO pin to become low (0v) again to indicate that the sent signal has been reflected from an abject and detected by the module.
5- When ECHO becomes (0V), we have to stop the timer .
6- use the time ( which is counted by the timer ) to calculate the distance and display the distance on the LCD .
can you just help me in writing this code with the following :
pic 16f628a
Trigger pin = RA5
Echo pin = RA4
Timer = Timer1
Oscillator is the internal oscillator of the same pic .
LCD can be connected to PORT B.
I want o write a code for a distance meter using Mikroc Pro , using ultrasonic sensor ( HC-SR04 ) , pic16f628a , and 16 *2 LCD .
What i understand about this sensor module is the following :
in the code :
1 - you have to end a trigger signal ( 5 V) .
2- delay_us(15),
3- set the trigger pin to be low ( 0 V) again , then the module will send a burst signal ( 40 Khz) .
3- after sending the signal, the ECHO pin will be high ( 5 v) automatically , so in the code we have to wait for this pin to be high .
4- when ECHO pin becomes high (5V) , we have to start the timer .and listening to the ECHO pin to become low (0v) again to indicate that the sent signal has been reflected from an abject and detected by the module.
5- When ECHO becomes (0V), we have to stop the timer .
6- use the time ( which is counted by the timer ) to calculate the distance and display the distance on the LCD .
can you just help me in writing this code with the following :
pic 16f628a
Trigger pin = RA5
Echo pin = RA4
Timer = Timer1
Oscillator is the internal oscillator of the same pic .
LCD can be connected to PORT B.