Trigger pin set to "input" ?

Issue #53 closed
Juergen Opschroef created an issue

Hello Tim,
first of all thanks alot for providing the library. It very much eases the usage of the Ultrasonic sensors.
I think there is an issue with the trigger pin: it is set to input while it should be set to output.

This is my setup:

  • Arduino Pro Mini 5V w/ Atmega328
  • JSN-SR04T-2.0
  • TRIGGER_PIN 7
  • ECHO_PIN 6

Sketch
I use your "Simple NewPing Sketch" with the modified trigger and echo pins.

Measurement:
Connecting an oscilloscope indictates that the Trigger pin is configured as an input while it should be configured as output.

The yellow graph represents the trigger pin and the blue the echo pin. The behaviour of the trigger pin follows the code in the library - but when wrongly configured as input:

*_triggerOutput &= ~_triggerBit; // Set the trigger pin low,
//should already be low, but this
// will make sure it is.
delayMicroseconds(4); // Wait for pin to go low.
*_triggerOutput |= _triggerBit; // Set trigger pin high, this tells
// the sensor to send out a ping.
delayMicroseconds(10); // Wait long enough for the sensor to
// realize the trigger pin is high.
// Sensor specs say to wait 10uS.
*_triggerOutput &= ~_triggerBit; // Set trigger pin back to low.

I think the issue is related to :

#define ONE_PIN_ENABLED true // Set to "false" to disable one pin
// mode which saves around 14-26 bytes
// of binary size. Default=true

The ONE_PIN_ENABLED remains set to true if not changed and hence the library assumes it is a one pin mode, always. By changing the value to false in the library the trigger pin works as expected:

Please let me know if you need more information or if I did not correctly use the library.

Have a nice day.

Jürgen

Comments (2)

  1. Tim Eckel repo owner

    It’s set to input so you can use the same pin for trigger and echo. You can turn this off if using two pins for trigger and echo.

  2. Log in to comment