Arduino Nano

Arduino basic Tutorial

Blynk iot Tutorial

Visit all the Links

ArduinoTutorial by Manmohan Pal

Blynk Tutorial to Control RGB LED iot

Blynk Tutorial to Control RGB LED iot





Sure! Here's a step-by-step tutorial on "Blynk Tutorial to Control RGB LED using IoT". This will show you how to control an RGB LED through the Blynk app using an IoT platform like Arduino.

Components Required:

  1. RGB LED (Common Cathode or Common Anode)
  2. Arduino (Uno, Nano, etc.)
  3. Jumper wires
  4. Breadboard (optional)
  5. Resistors (typically 220Ω for each color pin of the RGB LED)
  6. Wi-Fi Module (ESP8266/ESP32, or Arduino with Wi-Fi Shield)
  7. Smartphone with Blynk App
  8. Blynk Cloud Account

Step 1: Setup the Hardware

  1. Wiring the RGB LED:

    • An RGB LED has 4 pins: Red, Green, Blue, and Common Cathode or Common Anode.
    • For this tutorial, let's use a common cathode RGB LED (if you're using a common anode RGB LED, reverse the connection logic).

    Wiring for Common Cathode RGB LED:

    • Connect the common cathode (GND) pin to the ground (GND) of the Arduino.
    • Connect the Red pin of the RGB LED to pin 9 of the Arduino (through a 220Ω resistor).
    • Connect the Green pin of the RGB LED to pin 10 of the Arduino (through a 220Ω resistor).
    • Connect the Blue pin of the RGB LED to pin 11 of the Arduino (through a 220Ω resistor).
  2. Connecting the Wi-Fi Module (ESP8266):

    • Connect the VCC of the ESP8266 to 5V on the Arduino.
    • Connect the GND of the ESP8266 to GND on the Arduino.
    • Connect TX of the ESP8266 to RX of the Arduino.
    • Connect RX of the ESP8266 to TX of the Arduino.

Step 2: Install Blynk Library

  1. Open the Arduino IDE.
  2. Go to Sketch > Include Library > Manage Libraries.
  3. In the Library Manager, search for Blynk and install the Blynk library.

Step 3: Create a Blynk Project

  1. Sign up/Login to Blynk:

    • Download the Blynk app from the Google Play Store or Apple App Store.
    • Open the app and sign up/login.
  2. Create a new project:

    • In the Blynk app, click on "Create New Project".
    • Choose the device as your board (for example, ESP8266).
    • Choose the connection type as Wi-Fi.
    • Blynk will generate an Auth Token and send it to your email. This token will be used to link the app to the hardware.
  3. Add Widgets to the Blynk App:

    • Add three Slider Widgets (for Red, Green, and Blue) to control the RGB values.
    • Assign each slider to a virtual pin (V1 for Red, V2 for Green, V3 for Blue).
    • Adjust the slider values from 0 to 255 (for controlling RGB intensity).

Step 4: Write the Arduino Code

Here’s the basic code for controlling the RGB LED using the Blynk app:


/////////////////////////////////////////////////////

#define BLYNK_TEMPLATE_ID "......................"
#define BLYNK_TEMPLATE_NAME ".........................."
#define BLYNK_AUTH_TOKEN "................................"

#include <BlynkSimpleEsp8266.h>

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

int rled=14; //D5
int gled=12; //D6
int bled=13; //D7



char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Manmohan Pal"; //your hotspot name
char pass[] = "8989811397"; //your hotspot password name

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode(rled, OUTPUT);
  pinMode(gled, OUTPUT);
  pinMode(bled, OUTPUT);

}

void loop() {
  Blynk.run();
}

BLYNK_WRITE(V1){
  int redcolour = param.asInt(); // assigning incoming value from pin V1 to a variable
  analogWrite(rled,redcolour);
}

BLYNK_WRITE(V2){
  int bluecolour = param.asInt(); // assigning incoming value from pin V1 to a variable
  analogWrite(bled,bluecolour);
}
BLYNK_WRITE(V3){
  int greencolour = param.asInt(); // assigning incoming value from pin V1 to a variable
  analogWrite(gled,greencolour);
}

///////////////////////////////////////////////////

Explanation of the Code:

  1. Libraries and Wi-Fi Setup:

    • BlynkSimpleEsp8266.h is used to interface the ESP8266 with Blynk.
    • auth[], ssid[], and pass[] are used to configure the Blynk app with your Wi-Fi credentials and authorization token.
  2. Pin Setup:

    • The RGB LED is connected to digital pins 9, 10, and 11.
    • BLYNK_WRITE(V1), BLYNK_WRITE(V2), and BLYNK_WRITE(V3) are used to read the slider values from the app and control the LED's color.
  3. Loop:

    • The Blynk.run() function runs continuously and updates the values on the app.

Step 5: Upload the Code to Arduino

  1. Select your board and port from the Tools menu.
  2. Upload the code to your Arduino.

Step 6: Test the RGB LED Control

  1. Open the Blynk app on your phone.
  2. Connect the app to your Arduino by pressing the Play button.
  3. Use the sliders for Red, Green, and Blue to change the colors of the RGB LED. As you adjust the sliders, the LED's color should change in real time.

Troubleshooting Tips:

  • Make sure the Wi-Fi credentials are correctly entered in the code.
  • Ensure that the Auth Token in the code matches the one sent by the Blynk app.
  • Double-check the wiring to ensure proper connections.

Conclusion:

You have now successfully created an IoT project using the Blynk app to control an RGB LED! This tutorial can be expanded for more IoT control applications, including controlling multiple devices, sensors, or even automating tasks through Blynk's widgets.

Enjoy experimenting with Blynk and IoT!






Blynk Tutorial to Control RGB LED iot

RGB LED control,

IoT projects,

Blynk app tutorial,

IoT with Blynk,

RGB LED IoT,

Smart home project,

IoT Blynk app,

DIY IoT project,

Control RGB LED remotely,

Blynk IoT tutorial,

Internet of Things,

Blynk LED control,

RGB LED Blynk app,

Arduino RGB LED control,

Blynk app IoT project,

IoT automation,

Blynk tutorial,

RGB LED Arduino project,

Remote LED control,

Home automation IoT,

No comments:

Post a Comment