I am using and HC-06 Bluetooth module to control my RGB LED Light Strip through my phone. The program and Blynk connection for my Bluetooth control works perfectly. However, I am trying to implement a sound sensor into this project to sync the light strip with music. I have a program that works with the sound sensor by itself, but for some reason the sound sensor does not like being combined with Bluetooth. When I control the lights via bluetooth, the sound sensor is always activated. It works perfectly without the bluetooth module connected, but it never works when it is. I am using virtual pins and the ZERGBA to control the color of the light strip. I also have a virtual button to turn the lights on and off. This is all using an Arduino UNO and a Samsung Galaxy S10. Does anyone know what I am doing wrong with the sound sensor? Is there a way I could hook up the sound sensor with the bluetooth module and run smoothly? Is there a way I can code both the bluetooth control and sound control together using blynk? If so, please let me know. My code for my bluetooth control will be down below. Thank you.
#define BLYNK_PRINT Serial
#define redpin 11
#define greenpin 10
#define bluepin 9
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3); // RX, TX
#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "UWSgcK9SzqntDRBUCEzWpZILqcdsaAwj";
SoftwareSerial SerialBLE(2, 3); // RX, TX
void setup()
{
// Debug console
Serial.begin(9600);
SerialBLE.begin(9600);
Blynk.begin(SerialBLE, auth);
Serial.println("Waiting for connections...");
pinMode(redpin, OUTPUT);
pinMode(bluepin, OUTPUT);
pinMode(greenpin, OUTPUT);
digitalWrite(redpin, LOW);
digitalWrite(greenpin, LOW);
digitalWrite(bluepin, LOW);
}
BLYNK_WRITE(V0)
{
analogWrite(redpin, param[0].asInt());
analogWrite(greenpin, param[1].asInt());
analogWrite(bluepin, param[2].asInt());
}
BLYNK_WRITE(V3)
{
if (param.asInt()== 1)
{
analogWrite(greenpin, param[1].asInt());
analogWrite(redpin, param[0].asInt());
analogWrite(bluepin, param[2].asInt());
}
if (param.asInt()== 0)
{
analogWrite(redpin, 0);
analogWrite(greenpin, 0);
analogWrite(bluepin, 0);
}
}
void loop()
{
Blynk.run();
// You can inject your own code or combine it with other sketches.
// Check other examples on how to communicate with Blynk. Remember
// to avoid delay() function!
}