Last active
May 19, 2019 16:04
-
-
Save katsuyoshi/13fabee26be6693f07465ee44c2a031a to your computer and use it in GitHub Desktop.
Measure distance by Grove ultrasonic sensor using M5Stack.
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 <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