Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Measure distance by Grove ultrasonic sensor using M5Stack.
#include <M5Stack.h>
#include <Ultrasonic.h>
const int USONIC_PIN = 2;
Ultrasonic ultrasonic(USONIC_PIN);
void setup() {
M5.begin();
M5.Lcd.setTextSize(2);
}
void loop() {
long distance = ultrasonic.MeasureInCentimeters();
M5.Lcd.printf("Distance %ld cm\n", distance);
delay(5000);
}
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.