EARTH.ino 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. Description: Read the analog quantity and digital quantity returned by the EARTH unit, and convert the analog quantity into 12-bit data and display it on the screen.
  3. */
  4. #include <M5Stack.h>
  5. void setup() {
  6. M5.begin();
  7. M5.Power.begin();
  8. //disable the speak noise
  9. dacWrite(25, 0);
  10. M5.Lcd.setTextColor(YELLOW);
  11. M5.Lcd.setTextSize(2);
  12. M5.Lcd.setCursor(65, 50);
  13. M5.Lcd.printf("UNIT_EARTH EXAMPLE\n");
  14. pinMode(26, INPUT);
  15. M5.Lcd.setCursor(85, 80);
  16. M5.Lcd.print("GPIO36:");
  17. M5.Lcd.setCursor(85, 100);
  18. M5.Lcd.print("GPIO26:");
  19. }
  20. uint16_t analogRead_value = 0;
  21. uint16_t digitalRead_value = 0;
  22. void loop() {
  23. // put your main code here, to run repeatedly:
  24. M5.Lcd.setCursor(175, 80);
  25. M5.Lcd.setTextColor(BLACK);
  26. M5.Lcd.printf("%d\n", analogRead_value);
  27. M5.Lcd.setCursor(175, 100);
  28. M5.Lcd.printf("%d\n", digitalRead_value);
  29. analogRead_value = analogRead(36);
  30. digitalRead_value = digitalRead(26);
  31. M5.Lcd.setTextColor(YELLOW);
  32. M5.Lcd.setCursor(175, 80);
  33. M5.Lcd.printf("%d\n", analogRead_value);
  34. M5.Lcd.setCursor(175, 100);
  35. M5.Lcd.printf("%d\n", digitalRead_value);
  36. delay(10);
  37. }