We already have talked about using Blynk with Arduino. In this tutorial, we will make a DIY project using RGB LED with Blynk. We will also control the intensity of it using some special widgets in Blynk.
Contents: RGB LED with Blynk
- Introduction
- Materials Required
- Circuit and Explanation
- Arduino Code
- Adding Widgets in Blynk
- Finally running the project
Introduction
We have made many projects comprising the wireless communication. We use Bluetooth module, Wifi etc. With this project, we can do so by using Blynk. As explained in the introductory blog of Blynk, we need to give internet to the board. In this tutorial I will be using the serial communication. However, we can also use different ways like Wifi, Ethernet etc.
Materials Required
- RGB LED
- Arduino Uno
- Breadboard
- Jumper wires
- A mobile phone with Blynk app
Circuit and Explanation
As seen above, the circuit is not different from the normal setup excluding the setup. However, you need to be careful whether you are using Common anode LED or Common Cathode. The LED which I have used is the Common Anode, which means the common pin is the (+) pin. So we need to work in the Active Low.
Arduino Code
The code can be opened from the Examples present in the Blynk library. Since we are using the serial communication, so I have used the Arduino_serial_USB example from it. Below is the code.
#define BLYNK_PRINT DebugSerial
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX
#include <BlynkSimpleStream.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken"; // set your authentication token here
void setup()
{
// Debug console
DebugSerial.begin(9600);
// Blynk will work through Serial
// Do not read or write this serial manually in your sketch
Serial.begin(9600);
Blynk.begin(Serial, auth);
}
void loop()
{
Blynk.run();
}
Adding Widgets in Blynk
Now, we have stepped into the main task of adding the widgets in the App. First of all, make a new project as in the image as shown.
Click on the + sign at the top right corner and add three buttons for the same as shown.Now press any button and you ll see the following options as shown.
In the PIN option, you need to set the digital pin you are going to use. Since we are using the Common anode LED, so we will also write 1 at the starting and 0 at the end. Then change the MODE to SWITCH. You can also add a slider if you want to change the intensity of the color. Add three different buttons. Here, I have also used a slider for green light. You can also change the label of the button.
This is how the final layout will look like. However, you can change the positions of the widgets.
Finally running the project
Now, we are done with the setup, so it is the time for the final run. For this, first upload the code to the Arduino UNO. I am using serial setup for setting the internet to the board. So i have selected the same option in the connectivity section of the APP. After uploading the code, click on the play button on the top rightmost button of the app.
You will see a similar scenario. Everything is successfully set. The last option which we are using is the running of the blynk.ser file under the scripts section of the Blynk library. Go there and run it. Make sure you see the correct COM port there. Now enter the same COM port and press enter. Now, you are completely done with the process. It’s time to observe!
Start using your buttons present in the app. Use the slider too. I hope you were able to complete this project on RGB LED with Blynk. Feel free to comment and post your doubts too. Happy Learning!