//Learning Kit 2022 for M5Stack
//M5Stack_Gray_drv8833_dcmotor
#include <M5Stack.h>
void OpenScreen()
{
M5.Lcd.setCursor(0,0);
M5.Lcd.setTextColor(WHITE);
M5.Lcd.setTextSize(2);
M5.Lcd.print("Welcome to M5Stack Gray");
M5.Lcd.setCursor(0,20);
M5.Lcd.print("Coded by Kim Grossa");
M5.Lcd.setCursor(0,40);
M5.Lcd.print("Run dcmotor wiz DRV8833");
M5.Lcd.setCursor(0,70);
M5.Lcd.setTextColor(BLUE);
M5.Lcd.setTextSize(3);
M5.Lcd.print("ButtonA Reverse");
M5.Lcd.setCursor(0,100);
M5.Lcd.print("ButtonB Stop");
M5.Lcd.setCursor(0,130);
M5.Lcd.print("ButtonC Forward");
}
void setup()
{
M5.begin();
M5.Power.begin();
M5.Lcd.setBrightness(200);
pinMode(16,OUTPUT);
pinMode(17,OUTPUT);
}
void loop()
{
boolean aBtn = M5.BtnA.wasPressed();
boolean bBtn = M5.BtnB.wasPressed();
boolean cBtn = M5.BtnC.wasPressed();
OpenScreen();
if(aBtn)
{
//M5.Lcd.setCursor(0,180);
//M5.Lcd.setTextColor(GREEN,BLACK);
//M5.Lcd.setTextSize(3);
//M5.Lcd.print("Reverse........");
digitalWrite(16,LOW);
digitalWrite(17,HIGH);
//M5.Lcd.setCursor(0,180);
//M5.Lcd.setTextColor(GREEN,BLACK);
//M5.Lcd.setTextSize(3);
//M5.Lcd.print("Press any key..");
}
if(bBtn)
{
//M5.Lcd.setCursor(0,180);
//M5.Lcd.setTextColor(GREEN,BLACK);
//M5.Lcd.setTextSize(3);
//M5.Lcd.print("Stop.........");
digitalWrite(16,LOW);
digitalWrite(17,LOW);
//M5.Lcd.setCursor(0,180);
//M5.Lcd.setTextColor(GREEN,BLACK);
//M5.Lcd.setTextSize(3);
//M5.Lcd.print("Press any key");
}
if(cBtn)
{
//M5.Lcd.setCursor(0,180);
//M5.Lcd.setTextColor(GREEN,BLACK);
//M5.Lcd.setTextSize(3);
//M5.Lcd.print("Forward......");
digitalWrite(16,HIGH);
digitalWrite(17,LOW);
//M5.Lcd.setCursor(0,180);
//M5.Lcd.setTextColor(GREEN,BLACK);
//M5.Lcd.setTextSize(3);
//M5.Lcd.print("Press any key..");
}
M5.update();
}
0 件のコメント:
コメントを投稿