I have managed to get the led’s to work using a Slider widget set to (V1).The code is listed below. New to programming but very interested in the process so I can move forward.Here is the list of problems I am having:
- The starting led is brighter, almost white, and does not show a change in color when using the slider widget, but the other 8 led’s work great.
- I do not understand what I need to do to set up a (V2) as a button in order to turn On/Off the board’s data pin(12).
- I would also like to create a slider to adjust brightness of the led string as well.
Hoping for some help, but I understand there are much better projects than what I am asking for. Thank you!!
code
* App project setup:
* Slider widget (0...500) on V1
*
**************************************************************/
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Adafruit_NeoPixel.h>
#define PIN 12
Adafruit_NeoPixel strip = Adafruit_NeoPixel(9, PIN, NEO_GRB + NEO_KHZ800);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "XXXXXXXXXXXXXXXXXXXXX";
char ssid[] = "XXXXXXXXX";
char pass[] = "xxxxxxxxx";
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
strip.begin();
strip.show();
}
BLYNK_WRITE(V2)
}
int button =
BLYNK_WRITE(V1)
{
int shift = param.asInt();
for (int i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i, Wheel(shift & 255));
// OR: strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + shift) & 255));
}
strip.show();
}
void loop()
{
Blynk.run();
}
// 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) {
if (WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if (WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}