From 6ddc8e02bd1d8e438b20ff88f7c90432df6cdbbb Mon Sep 17 00:00:00 2001 From: david Date: Mon, 9 Oct 2023 14:18:19 -0700 Subject: [PATCH] Photon 2 code formatting --- .../voice-commands-particle-photon-2.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/audio-projects/voice-commands-particle-photon-2.md b/audio-projects/voice-commands-particle-photon-2.md index a6260d8b..0c53eeaf 100644 --- a/audio-projects/voice-commands-particle-photon-2.md +++ b/audio-projects/voice-commands-particle-photon-2.md @@ -132,7 +132,19 @@ pinMode(3, OUTPUT); // set pin 3 to control the Relay Module Then, inside the loop we will add this code to control the Relay. In this case, the label contains the keyword "muted" instead of "machine", as I was exploring audio output. If you are going to use another label, just change the word "muted" to the keyword contained in your own label. ``` - for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {
 if (strstr(result.classification[ix].label, "muted") && result.classification[ix].value > detectionLimit) {
 if (machineOn==1){
 ei_printf(" - Turning the machine off");
 digitalWrite(3, HIGH);
 machineOn=0;
 }
 else{
 ei_printf(" - Turning the machine on");
 digitalWrite(3, LOW);
 machineOn=1;

 } 
 } + for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) { + if (strstr(result.classification[ix].label, "muted") && result.classification[ix].value > detectionLimit) { + if (machineOn==1){ + ei_printf(" - Turning the machine off"); + digitalWrite(3, HIGH); + machineOn=0; + } + else{ + ei_printf(" - Turning the machine on"); + digitalWrite(3, LOW); + machineOn=1; + } + } ``` > Note: you can also download the `main.cpp` file from [https://github.com/ronibandini/Photon2VoiceCommand](https://github.com/ronibandini/Photon2VoiceCommand) to make sure you have everything entered correctly. @@ -177,8 +189,10 @@ Moreover, the compact form factor and cost-effectiveness of boards like the Part ## Contact -[https://www.instagram.com/ronibandini](https://www.instagram.com/ronibandini) +[https://www.instagram.com/ronibandini](https://www.instagram.com/ronibandini) + [https://twitter.com/RoniBandini](https://twitter.com/RoniBandini) + [https://bandini.medium.com](https://bandini.medium.com)