Hey, so I’m working on an app that controls my ambient lighting. This is my code:
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
Control a color gradient on NeoPixel strip using a slider!
For this example you need NeoPixel library:
https://github.com/adafruit/Adafruit_NeoPixel
App project setup:
Slider widget (0...500) on V1
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Adafruit_NeoPixel.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "1478b535924649d184cc223a944c0051";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Hope Siebzehn AP";
char pass[] = "47275552990710462457";
#define PIN D1
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
// 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);
}
}
BLYNK_WRITE(V1)
{
int shift = param.asInt();
for (int i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i, Wheel(shift & 255));
}
strip.show();
}
BLYNK_WRITE(V2) {
Serial.println("Knopf");
for (int i = 0; i < 60; i++)
{
strip.setPixelColor(i, strip.Color(0,0,0)); // Ausgeschaltet
}
strip.show();
}
BLYNK_WRITE(V3) {
Serial.println("Knopf");
for (int i = 0; i < 60; i++)
{
strip.setPixelColor(i, strip.Color(255,0,0)); // Rot
}
strip.show();
}
BLYNK_WRITE(V4) {
Serial.println("Knopf");
for (int i = 0; i < 60; i++)
{
strip.setPixelColor(i, strip.Color(51,51,255)); // Blau
}
strip.show();
}
BLYNK_WRITE(V5) {
Serial.println("Knopf");
for (int i = 0; i < 60; i++)
{
strip.setPixelColor(i, strip.Color(51,153,0)); // Grün
}
strip.show();
}
BLYNK_WRITE(V6) {
Serial.println("Knopf");
for (int i = 0; i < 60; i++)
{
strip.setPixelColor(i, strip.Color(255,255,0)); //Gelb
}
strip.show();
}
BLYNK_WRITE(V7)
{
for (int i = 0; i < 60; i++)
{
strip.setBrightness(param.asInt());
}
}
//Theatre-style crawling lights with rainbow effect
BLYNK_WRITE(V8) {
for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel
for (int q=0; q < 3; q++) {
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on
}
strip.show();
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
strip.begin();
strip.show();
}
void loop()
{
Serial.begin(57600);
Blynk.run();
}
I can’t get the last button (vPin 8) to run till I select another button. Kind of like an infinite loop, but one that I can break when I want to have just another colour. Can someone help me, please?