mirror of
https://github.com/m5stack/m5-docs.git
synced 2026-05-20 10:23:01 -07:00
...
This commit is contained in:
+28
-3
@@ -24,9 +24,34 @@ The Unit BUTTON is a sigle-button unit that can be detected whether the button p
|
||||
## Example
|
||||
|
||||
```arduino
|
||||
float tmp = dht12.readTemperature();//temperature
|
||||
float hum = dht12.readHumidity();//humidity
|
||||
float pressure = bme.readPressure();//pressure
|
||||
#include <M5Stack.h>
|
||||
void setup() {
|
||||
// init lcd
|
||||
M5.begin();
|
||||
pinMode(36, INPUT);
|
||||
M5.Lcd.clear(BLACK);
|
||||
M5.Lcd.setTextColor(YELLOW);
|
||||
M5.Lcd.setTextSize(2);
|
||||
M5.Lcd.setCursor(65, 10);
|
||||
M5.Lcd.println("Button example");
|
||||
M5.Lcd.setTextColor(RED);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
M5.update();
|
||||
|
||||
if(digitalRead(36)==0)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
if(digitalRead(36)==1)
|
||||
{
|
||||
M5.Lcd.print("1");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Click [here](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Unit/BUTTON/Arduino)for Specific example.
|
||||
|
||||
@@ -88,8 +88,7 @@
|
||||
|
||||
<!-- [](zh_CN/unit/rgb) [](zh_CN/unit/relay) [](zh_CN/unit/neopixel) -->
|
||||
|
||||
[](zh_CN/unit/hub) [](zh_CN/unit/396port)
|
||||
[](zh_CN/unit/proto)
|
||||
[](zh_CN/unit/hub) [](zh_CN/unit/396port) [](zh_CN/unit/proto)
|
||||
|
||||
<!-- [](zh_CN/unit/hub) [](zh_CN/unit/396port)
|
||||
[](zh_CN/unit/proto) -->
|
||||
|
||||
Reference in New Issue
Block a user