Timer Controller Made Easy with BlueBot: Set Start and End Times to Effortlessly Manage LEDs

Timer Controller: The BluBot Timer Controller enables users to control their LEDs with a precise start and end time. This feature allows you to turn on an LED at a specific starting time and turn it off at a specified ending time, all through Bluetooth communication. Perfect for applications that require automatic LED control based on a time schedule, this setup gives you flexibility while making device management simple.

In this guide, we’ll walk through the process of implementing a BlueBot Timer Controller for LED control using an Arduino and a Bluetooth module (such as the HC-05). You’ll learn how to set up the timing functionality, integrate Bluetooth communication, and control LEDs based on your defined times.

Timer Controller with BlueBot: Set Start and End Times to Control LEDs Control your LEDs with precise timing using the Bluetooth Timer Controller.

What is the BlueBot Controller App?

The Ultimate Bluetooth LED Controller App is a mobile application designed to control Bluetooth-enabled devices. The Blue Bot Controller is an all-in-one Bluetooth app designed for controlling devices like LEDs, robots, and sensors. It offers advanced features tailored for hobbyists, students, and developers alike.

With support for gesture, voice, IoT, and custom controls, the app enables seamless device management. Its user-friendly interface makes exploring wireless communication and automation effortless and engaging for all users.

Controllers:

  1. LED Control
  2. Robot Control
  3. RGB Control
  4. Text Control
  5. IoT Control
  6. Matrix Control
  7. Voice Control
  8. Gesture Control
  9. Sensor Control
    • MPU6050 Sensor : Gesture and motion detection.
    • Potentiometer Sensor: Analog value adjustments.
    • PIR Sensor: Motion detection triggering.
    • Ultrasonic Sensor: Distance and proximity measurements.
  10. Custom Control
  11. Timed Control
  12. Servo Control
  13. Joystick Control
  14. Inauguration Control

Features of the BlueBot Controller App

  • Simple Command Interface: Easily send commands like “ON” and “OFF” to control devices.
  • Customizable Buttons: Create custom commands to suit your project needs.
  • Real-Time Control: Instantly see the results of your actions.
  • Compatibility: Works seamlessly with Arduino and Bluetooth modules like HC-05 and HC-06.

How to Download the BlueBot Controller App

To get started, download the BlueBot Controller App from the official source:

Make sure you have a Bluetooth-enabled smartphone to pair with your project.

What Is the Bluetooth Timer Controller?

The Bluetooth Timer Controller is a time-based control system for switching LEDs on and off. With this setup, you can specify:

  • Starting time: The time at which the LED will turn on.
  • Ending time: The time at which the LED will turn off.

This setup is perfect for scenarios like automated lighting or controlling devices based on certain time windows. The controller works seamlessly with Bluetooth modules (like HC-05) to receive commands and set timers for the LED control.

Key Features of the BlueBot Timer Controller

  1. Set Start and End Times: You can define both the start time and end time for turning on and off the LEDs.
  2. Bluetooth Communication: Using a Bluetooth module (like HC-05), you can send commands wirelessly from your mobile device to control the LEDs.
  3. Multiple LEDs Control: You can control multiple LEDs with different timing settings.
  4. Automatic Control: The LEDs will turn on and off automatically at the set times, offering a hands-free, automated experience.

How It Works

In this setup, the BlueBot Timer Controller works by receiving time-related commands from your mobile device via Bluetooth. It listens for a start and end time and controls the LEDs accordingly.

Here’s an example of how you can control two LEDs (LED_PIN and LED_PIN1) based on the timing parameters sent over Bluetooth:

Code Explanation: BlueBot Timer Controller

// Define the pins for the LEDs
#define LED_PIN 13  // Change this to the appropriate pin number
#define LED_PIN1 12 // Change this to the appropriate pin number

#include <SoftwareSerial.h>

// RX and TX pins for Bluetooth module
#define RX_PIN 2
#define TX_PIN 3

SoftwareSerial bluetooth(RX_PIN, TX_PIN); // Create a Bluetooth serial object

void setup() {
  // Initialize the LED pins
  pinMode(LED_PIN, OUTPUT);
  pinMode(LED_PIN1, OUTPUT);
  digitalWrite(LED_PIN, LOW);  // Ensure LED1 is off initially
  digitalWrite(LED_PIN1, LOW); // Ensure LED2 is off initially

  // Start serial communication with the Bluetooth module
  bluetooth.begin(9600); // Bluetooth module baud rate
  Serial.begin(9600);    // Serial monitor (optional)

  Serial.println("Bluetooth LED Control Initialized");
}

void loop() {
  // Check if data is available from the Bluetooth module
  if (bluetooth.available()) {
    char command = bluetooth.read(); // Read the incoming command
    Serial.print("Received Command: ");
    Serial.println(command);

    // Handle the command
    switch (command) {
      case 'A':
        digitalWrite(LED_PIN, HIGH); // Turn LED1 on
        Serial.println("LED1 ON");
        break;

      case 'B':
        digitalWrite(LED_PIN, LOW); // Turn LED1 off
        Serial.println("LED1 OFF");
        break;

      case 'C':
        digitalWrite(LED_PIN1, HIGH); // Turn LED2 on
        Serial.println("LED2 ON");
        break;

      case 'D':
        digitalWrite(LED_PIN1, LOW); // Turn LED2 off
        Serial.println("LED2 OFF");
        break;

      default:
        Serial.println("Invalid Command");
        break;
    }
  }
}

Explanation Code of the Timer Controller

Pin Definitions:

  • LED_PIN and LED_PIN1 are set to control two different LEDs. You can modify these pin numbers based on the pins you’re using for your LEDs.

Bluetooth Setup:

  • We define RX_PIN and TX_PIN for Bluetooth communication. The SoftwareSerial library is used to set up communication between the Arduino and the Bluetooth module (HC-05).

Bluetooth Communication:

  • In the setup() function, we initialize the Bluetooth module at a baud rate of 9600 and start the Serial Monitor for debugging purposes.
  • In the loop(), we check if there is incoming data from the Bluetooth module. If there is, we read the command and perform an action (turning the LEDs on/off) based on the received command.

Command Handling:

  • Commands like ‘A’, ‘B’, ‘C’, and ‘D’ are used to control the LEDs.
    • ‘A’ turns LED_PIN (LED1) on.
    • ‘B’ turns LED_PIN (LED1) off.
    • ‘C’ turns LED_PIN1 (LED2) on.
    • ‘D’ turns LED_PIN1 (LED2) off.

Extension for Time Control:

To extend this code to allow time-based control of LEDs, we need to add a feature that reads the current time and compares it with the set start and end times. Here’s how we can implement it:

  1. Add start time and end time commands that will be sent from the mobile app to the Bluetooth module.
  2. Compare the current time with the set start and end times.
  3. Automatically turn the LEDs on and off based on the comparison.

Example of Time-Based Control:

// Additional Libraries for Time Handling
#include <TimeLib.h>

unsigned long startTime = 0;
unsigned long endTime = 0;

void setup() {
  // Initialize the LED pins
  pinMode(LED_PIN, OUTPUT);
  pinMode(LED_PIN1, OUTPUT);
  digitalWrite(LED_PIN, LOW);
  digitalWrite(LED_PIN1, LOW);

  bluetooth.begin(9600);
  Serial.begin(9600);
  
  setTime(10, 30, 0, 1, 1, 2025);  // Set current time for testing (Hour, Minute, Second, Day, Month, Year)
  Serial.println("Bluetooth Timer Control Initialized");
}

void loop() {
  if (bluetooth.available()) {
    char command = bluetooth.read();
    Serial.print("Received Command: ");
    Serial.println(command);

    if (command == 'S') {
      // Set start and end time (for example, start at 10:30 and end at 11:00)
      startTime = now() + 60 * 30;  // 10:30 AM (example)
      endTime = now() + 60 * 60;    // 11:00 AM (example)
      Serial.println("Timer Set");
    }
    
    // Check if current time is within the start and end times
    if (now() >= startTime && now() <= endTime) {
      digitalWrite(LED_PIN, HIGH); // Turn LED on during the set time range
    } else {
      digitalWrite(LED_PIN, LOW); // Turn LED off outside the set time range
    }
  }
}

Explanation of Timer Controller Code

  1. Time Library: The TimeLib library allows us to manage time and compare it against set start and end times.
  2. setTime(): You can manually set the current time for testing purposes, or you can configure a real-time clock (RTC) module for accurate timekeeping.
  3. startTime and endTime: These variables store the start and end times. The logic compares the current time (using now()) with these values.
  4. LED Control: Based on the current time, the code will automatically turn the LED on or off.

Conclusion

The Bluetooth Timer Controller is an excellent addition to projects requiring automated control of LEDs or other devices based on time. Whether you’re building a lighting system, automated project, or time-sensitive application, this setup ensures that your devices operate exactly when you want them to, without manual intervention.

By integrating Bluetooth communication and time control, the Bluetooth Timer Controller offers a high level of convenience and functionality for remote project management. With customizable start and end times, users can ensure their projects run smoothly and efficiently.

Try this setup today and enjoy the seamless automation that Bluetooth and time-based control offer!

For Timer Controller: Download BlueBot Controller App and start your journey today!

Home Page