M5Stack LED Blink
- 2018/09/18
- 23:49
M5Stack LED Blink
Hello everyone! I’m RoboTakao.
I have set up using M5Stack with Arduino IDE . I think I will try turning on the LED.

The M5Stack has a switch and LCD. Pushing the switch turns the LED on and off so that the LCD also shows the status.
Connection

Description of the sketch
To connect M5Stack's 22 pin to the LED, set the 22 pin mode to OUTPUT.
The output is controlled by inputting HIGH and LOW with the following instructions.
digitalWrite(Pin numbers, HIGH or LOW);
Character output to LCD is done with M5.Lcd.printf ().
When I pushed the button, the LED turned on and off. Operation check
By the way, I confirmed that the output is 3.3V.

Sketch
#include
int LEDPinNo = 22;
void setup() {
// Initialize the M5Stack object
M5.begin();
M5.Lcd.printf("M5Stack LED Blink test:\r\n");
pinMode(LEDPinNo, OUTPUT); //22pin OUTPUT mode
}
void loop() {
if(M5.BtnA.wasPressed()) {
M5.Lcd.printf("wasPressed A \r\n");
M5.Lcd.printf("LED ON \r\n");
digitalWrite(LEDPinNo, HIGH);
}
if(M5.BtnB.wasPressed())
{
M5.Lcd.printf("wasPressed B \r\n");
M5.Lcd.printf("LED OFF \r\n");
digitalWrite(LEDPinNo, LOW);
}
M5.update();
}
Good bye! Thank you!
M5Stack related posts
1) M5Stack Arduino IDE initial setting (macOS)
2) M5Stack I tried Arduino IDE sample sketches
3) M5Stack I treid Avatar(Arduino IDE)
スポンサードリンク