Last active
December 25, 2017 02:29
-
-
Save skynettw/e1141430b3da6918f63be2f30f7ec9b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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