Skip to content

Instantly share code, notes, and snippets.

@skynettw skynettw/arduino-unit-12-2
Last active Dec 25, 2017

Embed
What would you like to do?
#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
You can’t perform that action at this time.