Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
Dec
Published

Smart Voice Controlled Light

Smart Voice Controlled Light is a good friend for the night blindness.

BeginnerFull instructions provided154
Smart Voice Controlled Light

Things used in this project

Hardware components

Arduino Uno Rev3
Seeed Studio Arduino Uno Rev3
×1
Grove - RGB LED Ring (20 - WS2813 Mini)
Seeed Studio Grove - RGB LED Ring (20 - WS2813 Mini)
×1
Seeed Studio Grove - Sound Sensor Based on LM358 amplifier - Arduino Compatible
×1
Grove Base Shield V2.0 for Arduino
Seeed Studio Grove Base Shield V2.0 for Arduino
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Connecting the components

Code

Code_LED

C/C++
#include "Adafruit_NeoPixel.h"
const int pinAdc = A0;

#define LED_COUNT 40
#define LED_PIN    2
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
uint32_t Off_All = strip.Color(0, 0, 0);
uint32_t Red = strip.Color(228, 58, 79);
uint32_t Green = strip.Color(64, 194, 91);
uint32_t Bule = strip.Color(39,140, 223);
uint32_t Colour_Box[3] = {Red,Green,Bule};
int changecolor = 0;


void Led_Control(uint32_t Led_num,uint32_t Color,bool Switch)
{
    
    for(int i=0; i<Led_num; i++) { 
      if(Switch)
      {
        strip.setPixelColor(i, Color);
        strip.show();
      }  
      else
      {
        strip.setPixelColor(i, Off_All);
        strip.show();    
    }
  }

}
 
void setup() {
  // put your setup code here, to run once:
  strip.setBrightness(255);
  strip.begin();
  strip.show(); 
}

void loop() {
  // put your main code here, to run repeatedly:
    int sound = 0;
    sound = analogRead(A0);
    if(sound > 250)
    {
        Led_Control(LED_COUNT,Colour_Box[changecolor],1);
        delay(8000);
    }    
    else
    {
        Led_Control(LED_COUNT,Colour_Box[changecolor],0);
        delay(100);
    }   
    if(changecolor < 2)
      changecolor += 1;
    else
      changecolor = 0; 
}

Credits

Dec
1 project • 0 followers

Comments