Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FASTLED_ALLOW_INTERRUPTS 0
- #include "FastLED.h"
- #include <ESP8266WiFi.h>
- #include <ESP8266mDNS.h>
- #include <WiFiUdp.h>
- #include <ArduinoOTA.h>
- const char* ssid = "MyCharterWiFi3e-2G";
- const char* password = "unevenlotus916";
- const char* host = "SNOW_FLAKE";
- FASTLED_USING_NAMESPACE
- //int lightPin = A7; //define a pin for Photo resistor
- #define NUM_STRIPS 4
- #define NUM_LEDS_PER_STRIP 28
- #define NUM_LEDS NUM_LEDS_PER_STRIP * NUM_STRIPS
- CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];
- #define BRIGHTNESS 255
- #define FRAMES_PER_SECOND 120
- void setup() {
- Serial.begin(115200);
- Serial.println("Booting");
- WiFi.mode(WIFI_STA);
- WiFi.begin(ssid, password);
- while (WiFi.waitForConnectResult() != WL_CONNECTED) {
- Serial.println("Connection Failed! Rebooting...");
- delay(5000);
- ESP.restart();
- }
- // Port defaults to 8266
- // ArduinoOTA.setPort(8266);
- // Hostname defaults to esp8266-[ChipID]
- ArduinoOTA.setHostname(host);
- // No authentication by default
- // ArduinoOTA.setPassword((const char *)"123");
- ArduinoOTA.onStart([]() {
- Serial.println("Start");
- });
- ArduinoOTA.onEnd([]() {
- Serial.println("\nEnd");
- });
- ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
- Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
- });
- ArduinoOTA.onError([](ota_error_t error) {
- Serial.printf("Error[%u]: ", error);
- if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
- else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
- else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
- else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
- else if (error == OTA_END_ERROR) Serial.println("End Failed");
- });
- ArduinoOTA.begin();
- Serial.println("Ready");
- Serial.print("IP address: ");
- Serial.println(WiFi.localIP());
- // tell FastLED there's 60 NEOPIXEL leds on pin 10, starting at index 0 in the led array
- FastLED.addLeds<NEOPIXEL, D4>(leds, 0, NUM_LEDS_PER_STRIP);
- // tell FastLED there's 60 NEOPIXEL leds on pin 11, starting at index 60 in the led array
- FastLED.addLeds<NEOPIXEL, D3>(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);
- // tell FastLED there's 60 NEOPIXEL leds on pin 12, starting at index 120 in the led array
- FastLED.addLeds<NEOPIXEL, D2>(leds, 2 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);
- // tell FastLED there's 60 NEOPIXEL leds on pin 12, starting at index 120 in the led array
- FastLED.addLeds<NEOPIXEL, D1>(leds, 3 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);
- delay(5000); // 3 second delay for recovery
- // tell FastLED about the LED strip configuration
- // FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
- //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
- // set master brightness control
- // FastLED.setBrightness(analogRead(lightPin));
- FastLED.setBrightness(BRIGHTNESS);
- }
- void loop() {
- ArduinoOTA.handle();
- // brightness();
- pride();
- FastLED.show();
- }
- void pride()
- {
- static uint16_t sPseudotime = 0;
- static uint16_t sLastMillis = 0;
- static uint16_t sHue16 = 0;
- uint8_t sat8 = beatsin88( 87, 220, 250);
- uint8_t brightdepth = beatsin88( 341, 96, 224);
- uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
- uint8_t msmultiplier = beatsin88(147, 23, 60);
- uint16_t hue16 = sHue16;//gHue * 256;
- uint16_t hueinc16 = beatsin88(113, 1, 3000);
- uint16_t ms = millis();
- uint16_t deltams = ms - sLastMillis ;
- sLastMillis = ms;
- sPseudotime += deltams * msmultiplier;
- sHue16 += deltams * beatsin88( 400, 5,9);
- uint16_t brightnesstheta16 = sPseudotime;
- for( uint16_t i = 0 ; i < NUM_LEDS; i++) {
- hue16 += hueinc16;
- uint8_t hue8 = hue16 / 256;
- brightnesstheta16 += brightnessthetainc16;
- uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
- uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
- uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
- bri8 += (255 - brightdepth);
- CRGB newcolor = CHSV( hue8, sat8, bri8);
- uint16_t pixelnumber = i;
- pixelnumber = (NUM_LEDS-1) - pixelnumber;
- nblend( leds[pixelnumber], newcolor, 64);
- }
- }
- /*void brightness(){
- int val = analogRead(lightPin);
- val = map(val, 0, 1023, 64, 255);
- FastLED.setBrightness(val);
- Serial.println(val); //Write the value of the photoresistor to the serial monitor.
- }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement