記事一覧

M5Stack LED Blink

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.

M5stack42.jpg

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

M5stack44.png

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.

M5stack41.jpg

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)

スポンサードリンク

コメント

コメントの投稿

非公開コメント

プロフィール

RoboTakao

Author:RoboTakao
みなさんご訪問ありがとうございます。ロボット作りたいけどお小遣いそんなにないし、簡単でローコストでロボットを作るための私のプロジェクトを紹介します。

ウェブサイトもありますのでそちらもよろしくお願いします。
http://robotakao.jp/

スポンサーリンク