Skip to content

Instantly share code, notes, and snippets.

@skynettw
Last active December 25, 2017 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skynettw/e1141430b3da6918f63be2f30f7ec9b7 to your computer and use it in GitHub Desktop.
Save skynettw/e1141430b3da6918f63be2f30f7ec9b7 to your computer and use it in GitHub Desktop.
#include "NewPing.h"
#include "Wire.h"
#include "LiquidCrystal_I2C.h"
#define TRIGpin 2
#define ECHOpin 3
#define MaxDistance 200
NewPing m(TRIGpin, ECHOpin, MaxDistance);
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3,POSITIVE);
void setup() {
lcd.begin(16,2);
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("NKFUST Maker!!!");
delay(1000);
}
void loop() {
delay(100);
int us = m.ping();
if (us>0) {
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(m.convert_cm(us));
lcd.write("cm");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment