Hi all,
I will need your help on a program that I am in the process of making.
I want to control an RGB LED strip (12V DC) and a fan (PWM) via the BLYNK application.
For this I have an Arduino UNO board and an ESP32 (we do not only use the ESP32 card because we need the ARDUINO UNO card to power our fan and our LEDs in 12V).
I have the code for the Arduino UNO as well as for the ESP32 but I don't know which code to use to link the ESP32 to the Arduino.
Thank you in advance for your help
Attached are the codes for the 2 cards.
Code of Arduino Uno
int RedPin = 10; //Arduino driving pin for Red
int GreenPin = 11; //Arduino driving pin for Green
int BluePin = 9; //Arduino driving pin for Blue
int analogPin = 0;
int pinFan = 3;
int val = 0;
int pinPulse = 5;
void setColor(int red, int green, int blue)
{
analogWrite(RedPin, red);
analogWrite(GreenPin, green);
analogWrite(BluePin, blue);
}
void setup() {
pinMode(RedPin, OUTPUT); //Init Arduino driving pins
pinMode(GreenPin, OUTPUT);
pinMode(BluePin, OUTPUT);
Serial.begin(9600);
pinMode(pinFan, OUTPUT); //en D3
pinMode(pinPulse, INPUT); //en D5
Serial.begin(9600); //Set serial baud rate to 9600 bps
Serial.begin(9600);
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
;
}
}
void loop()
{
analogWrite(RedPin,0);
analogWrite(GreenPin,0);
analogWrite(BluePin,255);
delay(1000);
int val;
val = Serial.read();
analogWrite(pinFan, val / 4);
// run over and over
if (Serial.available()) {
Serial.write(Serial.read());
}
}
Code of ESP32
#define BLYNK_PRINT Serial
#define BLYNK_USE_DIRECT_CONNECT
#include <BlynkSimpleEsp32_BLE.h>
#include <BLEDevice.h>
#include <BLEServer.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "yawVHYjwOfD_OYqepg7fFQxAgXFaeIF-";
BLYNK_WRITE(V0)
{
int Value = param.asInt(); // assigning incoming value from pin V1 to a variable
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Blynk.virtualWrite(V0,Value);
Serial.print("V0 Slider value is: ");
Serial.println(Value);
}
void setup()
{
// Debug console
Serial.begin(9600);
Serial1.begin(9600);
Serial.println("Waiting for connections...");
Blynk.setDeviceName("Siluxe");
Blynk.begin(auth);
}
void loop()
{
Blynk.run();
}