cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

trawakarolek_49
New Contributor

Hello, I am new to the psoc product. I'm trying to use a distance sensor. The firmware does not work as it should and I do not know if it is the fault of a faulty sensor or software errors. The sensor is connect correctly (the pins are exactly the same as in the psoc wizard). The sensor shows a random value and does not refresh it until I lift the object (large cardboard) above the sensor, I put it in another place in the plug, a different value is displayed, not similar to the real one. Can someone please help me?

0 Likes
1 Solution
EvPa_264126
Valued Contributor II

The trigger pulse must be very short (~ 10 microseconds):
............................
for(;;)
{
/* Place your application code here. */
// while(echo_Read() == 0 )
// {
Trigger_out_Write(1);
CyDelayUs(10u); // positive Trigger pulse time 10 microseconds
Trigger_out_Write(0);
CyDelay(1); // waiting for sending 8 pulses (0,5 mSec)
// }
while(echo_Read() == 1){};
...............................

diagram.png


On this forum you will find many examples of working with the HC-SRO4.

eg: Ultrasonic Distance Sensor HC-SRO4

View solution in original post

0 Likes
1 Reply
EvPa_264126
Valued Contributor II

The trigger pulse must be very short (~ 10 microseconds):
............................
for(;;)
{
/* Place your application code here. */
// while(echo_Read() == 0 )
// {
Trigger_out_Write(1);
CyDelayUs(10u); // positive Trigger pulse time 10 microseconds
Trigger_out_Write(0);
CyDelay(1); // waiting for sending 8 pulses (0,5 mSec)
// }
while(echo_Read() == 1){};
...............................

diagram.png


On this forum you will find many examples of working with the HC-SRO4.

eg: Ultrasonic Distance Sensor HC-SRO4

View solution in original post

0 Likes