Is the Grove port on the M5Stack Basic Core digital or analog?
-
I'm trying to connect this Seeed Studio button but not having any luck https://www.seeedstudio.com/Grove-Button.html.
Here is the code:
#include <M5Stack.h>
int last_value = 0;
int cur_value = 0;void setup() {
M5.begin(); // Init M5Stack.
M5.Power.begin(); // Init power.
pinMode(21, INPUT); // set pin mode to input.
M5.Lcd.setTextColor(YELLOW); // Set the font color to yellow.
M5.Lcd.setTextSize(2); // Setting the Font size.
M5.Lcd.setCursor(80, 0); // Set the cursor position to (80,0).
M5.Lcd.println("Button example");
M5.Lcd.setTextColor(WHITE);
}void loop() {
cur_value = digitalRead(21); // read the value of BUTTON.
M5.Lcd.setCursor(80, 25);
M5.Lcd.print("Button");
M5.Lcd.setCursor(0, 45);
M5.Lcd.print("Value: ");
M5.Lcd.setCursor(0, 85);
M5.Lcd.print("State: ");
if (cur_value != last_value) {
M5.Lcd.fillRect(85, 45, 75, 85, BLACK); // Draw a black rectangle 75 by 85 at (85,45).
if (cur_value == 0) {
M5.Lcd.setCursor(95, 45);
M5.Lcd.print("0"); // display the status
M5.Lcd.setCursor(95, 85);
M5.Lcd.print("pre");
} else {
M5.Lcd.setCursor(95, 45);
M5.Lcd.print("1"); // display the status
M5.Lcd.setCursor(95, 85);
M5.Lcd.print("rel");
}
last_value = cur_value;
}
}Thanks in advance.
-
The Red One?
Its I2C/ digital
-
Thanks ajb2k3. I have established that I have an I2C device at address 0x53. The device is a Seeed Studio101020054 Grove - 3-Axis Digital Accelerometer. Now how do I read a value from that address?
Thanks again.
-
https://github.com/Seeed-Studio/Accelerometer_ADXL345
This is all you need to get a demo running.
-You will also have to install these libraries:
#include <Wire.h>
#include <ADXL345.h> -
Thanks #teastain that works!
I simply changed ADXL345 accel(ADXL345_STD) to ADXL345 accel(ADXL345_ALT) in example code ReadXYZ.ino.
Thanks again.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login