McLighting icon indicating copy to clipboard operation
McLighting copied to clipboard

sound reactive and google assist help

Open deppen12 opened this issue 5 years ago • 1 comments

hi everyone. i'm not able to find any help regarding google assist for McLighting . how to connect it with google . i'm able to connect it cloudmqtt but not with google.

also i want to use audio / sound reactive function. how can i use this function ( https://www.instructables.com/id/Sound-Reactive-WS2812-LEDs-With-Arduino-and-Sound-/ )

#include <Adafruit_NeoPixel.h> #ifdef AVR #include <avr/power.h> #endif

int outputValue=0; int rememberOutputValue; int randNumber; int counter = 0; int loopCounter = 0;

#define PIN 6

#define NUMPIXELS 25

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() { // put your setup code here, to run once: pixels.begin(); randomSeed(analogRead(0)); Serial.begin(9600); }

// Input a value 0 to 255 to get a color value. // The colours are a transition r - g - b - back to r. uint32_t Wheel(byte WheelPos) { WheelPos = 255 - WheelPos; if(WheelPos < 85) { return pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3,0); } if(WheelPos < 170) { WheelPos -= 85; return pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3,0); } WheelPos -= 170; return pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0,0); }

void loop() { // put your main code here, to run repeatedly

// read the analog in value 100 times and count high levels

int sensorValue; counter = 0;

for (int i=0; i < 100; i++) { sensorValue = analogRead(A0); if(sensorValue > 500) counter++; }

if(map(counter, 0, 60, 0, 24) > outputValue)outputValue = map(counter, 0, 40, 0, 24); else if(loopCounter %2 == 0)outputValue-=1;

if(outputValue < 0) outputValue = 0; if(outputValue > 24) outputValue = 24;

if(loopCounter % 60 == 0)randNumber = random(255); loopCounter++;

// clear all LEDs for(int i=0;i < NUMPIXELS;i++){

// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(0,0,0, 255)); 

}

if(rememberOutputValue != outputValue) {
for(int i=24;i > (24-outputValue) || (outputValue == 24 && i == 0);i--){ pixels.setPixelColor(i, Wheel((randNumber) & 255)); }

pixels.show(); // This sends the updated pixel color to the hardware }
rememberOutputValue = outputValue; }

deppen12 avatar May 15 '19 09:05 deppen12

any help

deppen12 avatar Jul 03 '19 14:07 deppen12