arduino - Wemos D1 mini freezing afer a few minutes -
i´m using wemos d1 mini board control rgb led strip , programmed simple code arduino ide. wemos conects internet fine , ip adress can change rgb values of strip. works after few minutes board freezes , nothing works. after reset works again.
i conected simple circuit board controle rgb-led strip few transistors nothing should cause issue , if conect nothing board problem occurs.
i tested example wemos library there same problem. here code used (and sorry if code isn´t programmed i´m beginner ;)):
#include <esp8266wifi.h> const char* ssid = "my ssid"; const char* pass = "my password"; void setup() { pinmode(d1, output); pinmode(d2, output); pinmode(d5, output); wifi.begin(ssid, pass); while (wifi.status() != wl_connected) delay(500); serial.begin(9600); //serial.println(wifi.localip()); server.begin(); } void setcolor(string rgb) { string rgb_val = rgb.substring(4, rgb.lastindexof('h')); string red_val = rgb_val.substring(1,rgb_val.indexof(':')); string green_val = rgb_val.substring(rgb_val.indexof(':') + 1,rgb_val.indexof(':',rgb_val.indexof(':') + 1)); string blue_val = rgb_val.substring(rgb_val.lastindexof(':') + 1); int redval = red_val.toint(); int greenval = green_val.toint(); int blueval = blue_val.toint(); analogwrite(d5, redval); analogwrite(d2, greenval); analogwrite(d1, blueval); redval = redval >= 1023 ? 1023 : redval <= 0 ? 0 : redval; if (redval == 0) analogwrite(d5, 0); greenval = greenval >= 1023 ? 1023 : greenval <= 0 ? 0 : greenval; if (greenval == 0) analogwrite(d1, 0); blueval = blueval >= 1023 ? 1023 : blueval <= 0 ? 0 : blueval; if (blueval == 0) analogwrite(d2, 0); return; } void loop() { wificlient client = server.available(); if (!client) return; while (!client.available()) delay(1); string request = client.readstringuntil('\r'); client.flush(); //serial.print(request); setcolor(request); client.stop(); client.print("http/1.1 200 ok\r\n"); client.flush(); return; } is there know have done wrong?
Comments
Post a Comment