5v sonar (HC-SR04) and distance sensing robot example

Posted on
  • Hi, everybody.

    I am new to Espruino, and I would like to build a little robot like the distance sensing one.

    There is a thing I don't understand about the sonar. The source code reads:

    var TRIG = A0; // ultrasonic trigger
    var ECHO = A1; // ultrasonic echo signal
    

    but one should avoid connecting 5v input to the pins marked as '3.3v'.

    Now, the sonar used in the example is a HC-SR04, and its output is set to 5V. Shouldn't it be connected to one of the general purpose I/O pins, chosing one which is NOT marked as 3.3V?

    L.

  • Yes, that's a good point! While the 'trigger' is fine as it's an output, the echo signal shouldn't really go into a pin that's marked as 3.3v - and A1 is marked as only taking 3.3v for the Espruino Board.

    However, if you're using the Espruino Pico then it's fine - basically everything there is 5v tolerant.

  • Thanks for the reply.

    I'm using the standard board, rev. 1.4b.

    By the way, for the motors the code reads:

    var MOTORS = [A3,A2,B10,B11]; // pins for the motors
    

    but the board doesn't have such pins. I guess the example is based on an old board.

    L.

  • Ahh - it does have the pins (See http://www.espruino.com/EspruinoBoard), but they're in the pin strip in the middle of the board.

    They were used because when soldering a motor driver onto the proto area it made a lot of sense.

  • Ooops, sorry! I was searching only the side columns, not the middle area. Makes sense now ;-)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

5v sonar (HC-SR04) and distance sensing robot example

Posted by Avatar for loris @loris

Actions