Mood Lamp Project

I am making a mood lamp.

Triggering it with IFTTT.

Here is the code


#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#define RED A4
#define GREEN 3
#define BLUE 6
WidgetLED led(V1);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";

void setup()
{
  /*   put your setup code here, to run once:
 USE PWM PINS(D3,5,6,9,10,11) FOR ANALOG OUTPUT
 A4 for RED
 D3 for GREEN
 D6 for BLUE 
 Set one pin each for a trigger word
OUTPUTS
 D2 for HAPPY(yellow)
 D4 for SAD(purple)
 D7 for angry(red)
 D8 for elation(orange)
 A2 FOR BLUE
 D3 FOR GREEN  
 */
pinMode(2, INPUT); // trigger for happy(yellow)
pinMode(4, INPUT); // trigger for sad(purple)
pinMode(7, INPUT); // trigger for angry(red)
pinMode(8, INPUT); // trigger for elation(orange)
pinMode(A2,INPUT); // trigger for blue
pinMode(A3,INPUT); // trigger for green

pinMode(RED, OUTPUT); // RED CONNECTION
pinMode(GREEN, OUTPUT); // GREEN CONNECTION
pinMode(BLUE, OUTPUT); // BLUE CONNECTION
  Serial.begin(9600);
  Blynk.begin(auth);
  // You can also specify server.
  // For more options, see BoardsAndShields/Arduino_Ethernet_Manual example
  //Blynk.begin(auth, "your_server.com", 8442);
  //Blynk.begin(auth, IPAddress(192,168,1,100), 8888);
}

void loop()
{
  Blynk.run();
int y = digitalRead(2);
int p = digitalRead(4);
int r = digitalRead(7);
int o = digitalRead(8);
int b = analogRead(A2);
int g = analogRead(A3);
if (y!=0)
{
analogWrite(RED, 255); // COLOR COMBINATION FOR YELLOW
analogWrite(GREEN,153);
analogWrite(BLUE,0);
}
if (p!=0)
{
analogWrite(RED,102); // COLOR COMBINATION FOR PURPLE
analogWrite(BLUE,153);
analogWrite(GREEN,0);  
}
if (r!=0)
{
analogWrite(RED,255); // COLOR COMBINATION FOR RED
analogWrite(GREEN,0);
analogWrite(BLUE,0);
}
if (o!=0)
{
analogWrite(RED,255);  // COLOR COMBINATION FOR ORANGE
analogWrite(GREEN,153);
analogWrite(BLUE,0);
}

  if (b!= 0)
{
analogWrite(RED,0);  // COLOR COMBINATION FOR BLUE
analogWrite(GREEN,0);
analogWrite(BLUE,255);

}
if(g!=0)
{
analogWrite(RED,0);  // COLOR COMBINATION FOR GREEN
analogWrite(GREEN,255);
analogWrite(BLUE,0);
led.on();
}
}

After this in the serial monitor it shows flood error. Can someone tell me how to get out off this?

Please follow documentation examples.

I did. I am not able to understand it properly and how it will apply to this project

Ok, I’ll write code for you.

SimpleTimer timer;
WidgetLED led(V1);

void send()       
{
 if (analogRead(A3) != 0) {
    led.on();
 } 
}

void setup()
 {
   pinMode(A3,INPUT); // trigger for green
   Serial.begin(9600); // See the connection status in Serial Monitor
   Blynk.begin(auth);
   timer.setInterval(1000L, send);
 }

void loop()
{
  Blynk.run();
  timer.run(); // Initiates SimpleTimer
}

Thanks Dmitri.

I am sorry if this comment looks foolish.
I am a noob at coding.

Do i have write all the conditions in the void send() function?
Like all the analogwrite statements?

@Dmitriy I got this part working. But there is a problem with IFTTT. It’s not picking up my latest tweet but rather a series of them. So my lamp is switching colors instantaneously, which is ruining all the fun. Do you know what is their interval of checking?

Anyone ? @Pavel @vshymanskyy @Costas

Please provide more details. Is it a Blynk problem or IFFFT. To be honest I didn’t understand what is the issue.

Suppose I have this system.

For a single tweet only one LED should light up but The system is switching between the ultimate and the pen-ultimate tweets. I have assigned each trigger word in tweet to a particular LED.

Only one led should light up at a particular time but this is not happening. I have a video to show that but I can’t attach it here.

Thanks.

My project is working fine now