Things used in this project

Hardware components:
Esquilo%20top%20small
Esquilo Air
×1
51gzz5eu9pl. sx425
Ultrasonic Sensor - HC-SR04 (Generic)
×1
181 02
Adafruit Standard LCD - 16x2 White on Blue
×1
09939 01
Rotary potentiometer (generic)
10k pot
×1
12002 04
Breadboard (generic)
×1
Male/Male Jumper Wires
I used: 5 red, 5 black, 2 white, 3 orange, 1 yellow, 2 green, 2 blue
×20

Schematics

Esquilo HC-SR04 1602A wiring diagram
Esquilo HC-SR04 1602A wiring diagram
Wvon49hbtkthxf2qsrml
Esquilo HC-SR04 Ultrasonic library
Port of Arduino Ultrasonic library to Esquilo
Esquilo 1602A library
Port of Arduino LiquidCrystal library to Esquilo

Code

Esquilo HC-SR04 1602A example codePlain text
Esquilo HC-SR04 1602A example code
// HC-SR04 Ultrasonic Range Finder output to 1602A LCD

require("GPIO");
require("Capture");

dofile("sd:/LiquidCrystal.nut");

trigPin <- GPIO(13);  // HC-SR04 trigger pin (output)
echoPin <- Capture(1);  // HC-SR04 echo pin (input)

trigPin.output();

local duration;
local distance;

local lcd = LiquidCrystal(0x00, 12, 0, 11, 5, 4, 3, 2, 0, 0, 0, 0);

// set up the LCD's number of columns and rows: 
lcd.begin(16, 2, 0);

while (true) {
    lcd.clear();
    lcd.home();
    trigPin.low();
    delay(2);
    trigPin.high();
    delay(10);
    trigPin.low();
    echoPin.arm(0, CAPTURE_EDGE_RISING);
    duration = echoPin.read(0);
    //print("duration=" + duration);
    distance = (duration / 2) / 29.1;
    //print("distance=" + distance);
    // Print a message to the LCD.
    lcd.print("distance=" + distance);
    delay(500);
}

Credits

27eae0443d051e9e246159707c1f2203
Leeland Heins
4 projects • 0 followers
Hardware & Software H4x0r
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog