Created
November 9, 2021 13:34
-
-
Save numa08/f8a0a8272adb099874277ded1be825a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <M5StickCPlus.h> | |
// the setup routine runs once when M5Stack starts up | |
void setup(){ | |
// Initialize the M5Stack object | |
M5.begin(); | |
/* | |
Power chip connected to gpio21, gpio22, I2C device | |
Set battery charging voltage and current | |
If used battery, please call this function in your project | |
*/ | |
// LCD display | |
M5.Lcd.print("Hello World"); | |
M5.Beep.begin(); | |
} | |
int volume = 0; | |
// the loop routine runs over and over again forever | |
void loop() { | |
if (volume < 10) { | |
ledcWriteTone(0, 1800); | |
ledcWrite(0, 0x400 >> volume); | |
// M5.Beep.setVolume(volume); | |
// M5.Beep.tone(1800, 500); | |
delay(500); | |
ledcWriteTone(TONE_PIN_CHANNEL, 0); | |
digitalWrite(2, 0); | |
delay(500); | |
// M5.Beep.mute(); | |
volume++; | |
Serial.printf("volume %d\n", volume); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment