Problem speaker with M5stickC Plus
-
I am using M5stickc plus at the moment I am very happy with them, but I have had a problem and I cannot find a solution.
I am unable to make a beep sound and I am not listening because, I am attaching the code to see if they can help me.ERRROArduino:1.8.13 (Windows 10), Tarjeta:"M5Stick-C, Default, 1500000, None"
C:\DISEÑOS\Arduino\sketch_nov25b\sketch_nov25b.ino: In function 'void loop()':
sketch_nov25b:51:8: error: 'class M5StickCPlus' has no member named 'Speaker'
exit status 1
'class M5StickCPlus' has no member named 'Speaker'Thanks in advance.
#include <M5StickCPlus.h>
#define INTERVALO_LED 200
#define INTERVALO_LECTURAS 1000uint8_t i = 12;// entre 7 y 12
unsigned long tiempo;
const int Led = 10;
unsigned long Tiempo_Led_Encendido = 0;
unsigned long Tiempo_entre_Lecturas = 0;void setup() {
Serial.begin(115200);
// put your setup code here, to run once:
M5.begin();pinMode (Led, OUTPUT);
digitalWrite (Led, HIGH);
M5.Lcd.setRotation(1); //Rotar LCD
M5.Lcd.fillScreen(BLACK); //Vaciar pantalla y color
M5.Lcd.setTextColor(WHITE); //Color Texto
M5.Lcd.setTextSize(2); //Tamaño Texto
M5.Axp.ScreenBreath(i);
}void loop() {
M5.update(); // need to call update()
if (millis () > (Tiempo_entre_Lecturas + INTERVALO_LECTURAS))
{
M5.Lcd.fillScreen(BLACK); //Vaciar pantalla y color
M5.Lcd.setCursor(0, 0);
M5.Lcd.printf("V_Bateria: %.2fV\r\n", M5.Axp.GetBatVoltage());
M5.Lcd.printf("I_Bateria: %.1fmA\r\n", M5.Axp.GetBatCurrent());
M5.Lcd.printf("V_USB: %.3fV\r\n", M5.Axp.GetVBusVoltage());
M5.Lcd.printf("I_USB: %.3fmA\r\n", M5.Axp.GetVBusCurrent());
M5.Lcd.printf("Vin: %.3fV\r\n", M5.Axp.GetVinVoltage());
M5.Lcd.printf("Iin: %.3fmA\r\n", M5.Axp.GetVinCurrent());
M5.Lcd.printf("Bat power: %.3fmw\r\n", M5.Axp.GetBatPower());
M5.Lcd.printf("Nivel: %u\r\n", M5.Axp.GetWarningLeve());
Tiempo_entre_Lecturas = millis();
}
if(M5.BtnA.wasPressed())
{
digitalWrite (Led, LOW);
Serial.println("Pulsado A");
M5.Axp.ScreenBreath(i++);
M5.Speaker.beep();//////////*****///////
if (i > 12) i = 7;
Tiempo_Led_Encendido = millis();
}
if (!digitalRead(Led) & (millis () > (Tiempo_Led_Encendido + INTERVALO_LED)))
{
digitalWrite (Led, HIGH);
// M5.Speaker.setBeep(900, 1000);
}
} -
-
Thanks, you are a machine and fast.
-
Another issue, I cannot change the volume on my M5stack Plus. Some help?
-
Hi @vgamlc
I don't think you can change the volume of the beep. Although there is a
setVolume()function the volume is only used in thePlayMusic()function, but not for the beep.Please also refer to the Speaker source code
Thanks
Felix
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login