Raghavendra Ponuganti
Published © GPL3+

Voice, Blynk, Qmote Controlled Smart Light

Control the color of the light using "Voice", "Blynk" and "Qmote" . It can also react to Events in Android Phone.

IntermediateShowcase (no instructions)15 hours1,374
Voice, Blynk, Qmote Controlled Smart Light

Things used in this project

Hardware components

Spark Core
Particle Spark Core
×1
ULN2803
×1
Linear Regulator (7805)
Linear Regulator (7805)
×1
RGB LED Strip - Common Anode
×1
Android device
Android device
×1

Software apps and online services

Blynk
Blynk
Tasker
AutoVoice
RESTask for Tasker
Qmote

Story

Read more

Schematics

HW Schematic

Code

SW for Particle Core

C/C++
-> Change the Blynk auth code.
-> Build and flash the firmware to Particle Core using particle web ide.
// This #include statement was automatically added by the Particle IDE.
#include "SparkCorePolledTimer/SparkCorePolledTimer.h"

// This #include statement was automatically added by the Particle IDE.
#include "blynk/blynk.h"

char auth[] = "your blynk Auth code";


int LED_RED     = A5;
int LED_GREEN   = A7;
int LED_BLUE    = A4;

int redValue;
int greenValue;
int blueValue;

bool notiActionActive = 0;
int  notiActionCntr = 0;


SparkCorePolledTimer  cyclicTimer(750);

void CyclicFunction( void );

void setup() {
    pinMode(LED_RED,    OUTPUT);
    pinMode(LED_GREEN,  OUTPUT);
    pinMode(LED_BLUE,   OUTPUT);

    analogWrite(LED_RED,    0);
    analogWrite(LED_GREEN,  0);
    analogWrite(LED_BLUE,   0);
    
    redValue = 0;
    greenValue = 0;
    blueValue = 0;
    
    Particle.function("setColor",          processLEDColor);
    Particle.function("startNotiAct",   startNotificationAction);
    
    cyclicTimer.SetCallback(CyclicFunction);

    Blynk.begin(auth);
}

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

void setOutLEDColor(int rd, int grn, int blu)
{
    analogWrite(LED_RED,    rd);
    analogWrite(LED_GREEN,  grn);
    analogWrite(LED_BLUE,   blu);
}

/* Called from external world */
/* Set RGB LED Color */
int processLEDColor(String command)
{
    // Example pattern R(000),G(000),B(000)
    
    redValue = command.substring(2, 5).toInt();
    greenValue = command.substring(9, 12).toInt();
    blueValue = command.substring(16, 19).toInt();
    
    setOutLEDColor(redValue, greenValue, blueValue);
    return 1;
}

/* Called from external world */
/* Set RGB LED Color */
int startNotificationAction(String command)
{
    // Example pattern R(000),G(000),B(000)
    
    redValue = command.substring(2, 5).toInt();
    greenValue = command.substring(9, 12).toInt();
    blueValue = command.substring(16, 19).toInt();
    
    notiActionActive = 1;
    
    return 1;
}

/****************************************************************************
* Cyclic 1s function
******************************************************************************/
void CyclicFunction( void )
{
    if(notiActionActive == 1)
    {
        if(notiActionCntr < 20)
        {
            if((notiActionCntr % 2) == 1)
            {
                setOutLEDColor(redValue, greenValue, blueValue);
            }
            else
            {
                setOutLEDColor(0, 0, 0);
            }
            notiActionCntr++;
        }
        else
        {
            notiActionActive = 0;
            notiActionCntr = 0;
            setOutLEDColor(0,0,0);
        }
    }
}

Credits

Raghavendra Ponuganti

Raghavendra Ponuganti

3 projects • 10 followers

Comments

Add projectSign up / Login