Need help with some arduino code

nasune

Well-Known Member
OP
Member
Joined
Sep 13, 2009
Messages
758
Trophies
1
Age
36
XP
1,386
Country
Netherlands
Not sure if this is the correct section, if not I apologize, but I kind of need some help with some arduino code. A while back I bought a WS2812B LED matrix (8x8), and with a spare esp8266 chip the thing works pretty well. My only problem is that I've tried to use elegantOTA in order to make use of the chips wifi capabilities. Initially this seems to work well, I can upload new animations etcetera, but after about eight to ten times of looping through the animation the animation starts to lag/get stuck (it will only change very occasionally). I've put the code in the spoiler, so can anyone tell me what I'm doing wrong? (I'm not a coder/programmer by the way, at best I can kludge something together by looking at examples).

//#define FASTLED_ESP8266_RAW_PIN_ORDER
//#define FASTLED_ESP8266_NODEMCU_PIN_ORDER
#define FASTLED_ESP8266_D1_PIN_ORDER
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ElegantOTA.h>
#include <FastLED.h>

const char* ssid = "-";
const char* password = "-";

ESP8266WebServer server(80);

#define NUM_LEDS 64

#define DATA_PIN 5

CRGB leds[NUM_LEDS];


void setup() {
Serial.begin(9600);
LEDS.addLeds<WS2812,DATA_PIN,GRB>(leds,NUM_LEDS);
LEDS.setBrightness(32);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");

// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

server.on("/", []() {
server.send(200, "text/plain", "Hi! This is ElegantOTA Demo.");
});

ElegantOTA.begin(&server); // Start ElegantOTA
server.begin();
Serial.println("HTTP server started");
}


void loop()
{
server.handleClient();
ElegantOTA.loop();
leds [0] = 0xff22b14c; //start row 1
leds [1] = 0xff22b14c;
leds [2] = 0xff22b14c;
leds [3] = 0xff964800;
leds [4] = 0xff964800;
leds [5] = 0xff22b14c;
leds [6] = 0xff22b14c;
leds [7] = 0xff22b14c; //end row 1
leds [8] = 0xff22b14c; //start row 2
leds [9] = 0xff22b14c;
leds [10] = 0xff964800;
leds [11] = 0xff964800;
leds [12] = 0xff964800;
leds [13] = 0xff964800;
leds [14] = 0xff22b14c;
leds [15] = 0xff22b14c; //end row 2
leds [16] = 0xff22b14c; //start row 3
leds [17] = 0xff000000;
leds [18] = 0xff964800;
leds [19] = 0xff964800;
leds [20] = 0xff964800;
leds [21] = 0xff964800;
leds [22] = 0xff000000;
leds [23] = 0xff22b14c; //end row 3
leds [24] = 0xff964800; //start row 4
leds [25] = 0xfffee0a4;
leds [26] = 0xff000000;
leds [27] = 0xff000000;
leds [28] = 0xff000000;
leds [29] = 0xff000000;
leds [30] = 0xfffee0a4;
leds [31] = 0xff964800; //end row 4
leds [32] = 0xff964800; //start row 5
leds [33] = 0xfffee0a4;
leds [34] = 0xff000000;
leds [35] = 0xff964800;
leds [36] = 0xff964800;
leds [37] = 0xff000000;
leds [38] = 0xfffee0a4;
leds [39] = 0xff964800; //end row 5
leds [40] = 0xff22b14c; //start row 6
leds [41] = 0xff964800;
leds [42] = 0xff964800;
leds [43] = 0xff964800;
leds [44] = 0xff964800;
leds [45] = 0xff964800;
leds [46] = 0xff964800;
leds [47] = 0xff22b14c; //end row 6
leds [48] = 0xff964800; //start row 7
leds [49] = 0xff000000;
leds [50] = 0xfffee0a4;
leds [51] = 0xfffee0a4;
leds [52] = 0xfffee0a4;
leds [53] = 0xfffee0a4;
leds [54] = 0xff22b14c;
leds [55] = 0xff22b14c; //end row 7
leds [56] = 0xff22b14c; //start row 8
leds [57] = 0xff964800;
leds [58] = 0xff000000;
leds [59] = 0xfffee0a4;
leds [60] = 0xff000000;
leds [61] = 0xff000000;
leds [62] = 0xff000000;
leds [63] = 0xff22b14c; //end row 8
FastLED.show();

delay( 250 );

leds [48] = 0xff22b14c;
leds [49] = 0xff22b14c;
leds [54] = 0xff000000;
leds [55] = 0xff964800;
leds [57] = 0xff000000;
leds [59] = 0xff000000;
leds [60] = 0xfffee0a4;
leds [62] = 0xff964800;
FastLED.show();

delay( 250 );

}

The animation here is a simple Goomba moving its feet.
 
Last edited by nasune,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Sicklyboy @ Sicklyboy: Linus' personal account post regarding it - https://x.com/linusgsebastian/status/1822776600632709206