Arduino Nano

Arduino basic Tutorial

Blynk iot Tutorial

Visit all the Links

ArduinoTutorial by Manmohan Pal

IoT-based LED brightness control using Blynk

IoT-based LED brightness control using Blynk




Creating an IoT-based LED brightness control using Blynk is a great project to start with. While I can't directly provide a video, I can outline the steps for you, and you can use this as a guide to either find a tutorial video or follow the process.

Here’s a basic tutorial outline for controlling the brightness of an LED using Blynk:

Requirements:

  • Hardware:

    1. Arduino (e.g., Uno, Nano, or any other compatible board)
    2. LED
    3. Resistor (220Ω or appropriate for your LED)
    4. Jumper wires
    5. Breadboard (optional)
  • Software:

    1. Blynk App (on your smartphone)
    2. Arduino IDE
    3. Blynk Library

Step-by-Step Tutorial:

Step 1: Set Up the Blynk App

  1. Install the Blynk App: Download the Blynk app from the App Store (for iOS) or Google Play (for Android).
  2. Create a New Project:
    • Open the Blynk app and create a new project.
    • Select the device (e.g., Arduino Uno) and connection type (e.g., Wi-Fi, Ethernet).
    • You will receive an Auth Token via email or app notification. Save this token, as you’ll need it for your code.
  3. Add a Slider Widget:
    • In your Blynk project, add a slider widget from the widget box.
    • Set the slider range from 0 to 255 (this corresponds to the brightness level of the LED).
    • Set the slider to control Virtual Pin (V0).

Step 2: Set Up the Arduino

  1. Wiring the LED:
    • Connect the anode (longer leg) of the LED to the PWM-capable pin (e.g., Pin 9) of the Arduino.
    • Connect the cathode (shorter leg) to the GND pin on the Arduino through a 220Ω resistor.

Step 3: Install the Blynk Library in Arduino IDE

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

Step 4: Write the Code

Here’s the code to control the LED brightness:


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

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

#include <BlynkSimpleEsp8266.h>

#define BLYNK_PRINT Serial

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

int led0=16; //D0


char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = ".............."; //your hotspot name
char pass[] = ".............."; //your hotspot password name

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

}

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

BLYNK_WRITE(V0){
  int brightnessvalue = param.asInt(); // assigning incoming value from pin V0 to a variable
  analogWrite(led0,brightnessvalue);
}


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

  • Replace "YourBlynkAuthToken", "YourWiFiSSID", and "YourWiFiPassword" with your actual details.
  • The analogWrite() function controls the brightness, where the value passed (0-255) sets the LED intensity.

Step 5: Upload the Code

  • Select the correct board and port in Arduino IDE.
  • Upload the code to your Arduino board.

Step 6: Control LED Brightness

  • Open the Blynk app and connect to your project.
  • Use the slider to adjust the LED brightness. As you slide, the brightness of the LED should change in real-time.


No comments:

Post a Comment