Introduction: Use a LYT/WiFi Shield to Sync LYT Radio Bulb With Music

Picture of Use a LYT/WiFi Shield to Sync LYT Radio Bulb With Music

This simple project will show you how to sync your LYT bulb with music generating random RGB colors.

For this project you will need the following (over your arduino):

-One Authometion LYT/WiFi shield (www.authometion.com/shop)

-One 9W RGB-W LYT radio bulb (www.authometion.com/shop)

-One Adafruit Electret Microphone Amplifier (https://www.adafruit.com/products/1063)

Step 1: Interface the Microphone to the Arduino

Picture of Interface the Microphone to the Arduino

Connect the VCC Microphone pin to 3.3V arduino pin and the GND Microphone pin to one arduino GND pins.

For the best performance, use the "quietest" supply available (on an Arduino, this would be the 3.3V supply).

Then connect the OUT Microphone pin the arduino A0 analog input.

The audio waveform will come out of the OUT pin. The output will have a DC bias of VCC/2 so when its perfectly quiet, the voltage will be a steady VCC/2 volts (it is DC coupled).

Step 2: Upload Your Sketch!

Now you can upload the sketch on your arduino and test it.

In this code LYT address is 0,0 and PL1167 chip select is on pin 10 so please change them accordingly to your settings.

The sound level is continuosly acquired on A0 input and the audio peaks, both positive and negative, are calculated by subtracting the center value (340) to the read analog value and applying the ABS (absolute) function.

If this value goes over the threshold level SOUND_LEVEL a new random colors is sent to the LYT.

This will generate variations preferably on bass sounds.

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * *<br> Code by AUTHOMETION S.r.l.
 Version: 1.00
 Date: 02.06.2015
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <SPI.h>
#include <PL1167.h>
#include <Lytwifi.h>
#include <SoftwareSerial.h>
#include <WiFiInterrupt.h>
#define PL1167_CS_PIN     10
#define BULB_ADDRESS_HIGH 0
#define BULB_ADDRESS_LOW  0
#define SOUND_LEVEL 100
//ESP8266 Serial
SoftwareSerial mySerial(5, 6); // RX, TX
LYTWiFi myNetWork(mySerial);
void setup() 
{
  Serial.begin(115200, SERIAL_8N1);

  myNetWork.vfInitialize(PL1167_CS_PIN);
  vfISRInit(&myNetWork);
  
  //Initialize random generator
  randomSeed(analogRead(0));
}
void loop() 
{
    int adc_sound;
    
    //POWER ON LYT
    myNetWork.ui8fSwitchOnAndCheck(BULB_ADDRESS_HIGH, BULB_ADDRESS_LOW, C_MULTICAST);
    delay(2000);
 
    while(1)
    { 
      adc_sound=analogRead(0);             

      //CONNECT MICROPHONE VCC TO ARDUINO 3.3 VDC FOR BETTER PERFORMANCE	    
      adc_sound=abs(adc_sound - 350);// Center on zero
      if(adc_sound>SOUND_LEVEL) 
      {
     
        Serial.println(adc_sound);
        myNetWork.ui8fSetRGBValuesAndCheck(BULB_ADDRESS_HIGH, BULB_ADDRESS_LOW, random(255), random(255), random(255), C_MULTICAST);       
       
      }      
      
      
    } 
}

Step 3: And This Is Our Video! Enjoy!

Comments

tomatoskins (author)2015-07-06

Really cool idea! I think that a video of this would be super awesome!

AUTHOMETION (author)tomatoskins2015-07-06

Hi tomatoskins,

thank you!

This is only our first instructables and it was more an exercise for us!

We will sure add a video as per your suggestion and more instructables very soon!

tomatoskins (author)AUTHOMETION2015-07-06

That's Awesome!

gada888 (author)2015-07-08

nice tutorial,but how to get the libraries used in sketch.

AUTHOMETION (author)gada8882015-07-09

Hi gada888, you can find everything on our web store on each products page.

For example you can find libraries here (bottom page):

http://authometion.com/shop/it/home/3-kit-shield-l...

About This Instructable

1,829views

15favorites

License:

More by AUTHOMETION:HOW TO CONTROL a WiFi LYT8266 LED BULB  WITH BLYNK IN 5 MINUTESAutomatic lighting management using ambient soundsUse a LYT/WiFi shield to sync LYT radio bulb with music
Add instructable to: