hi,
i have a problem in my project:
some series of ws2812 leds connected to pin 5 of my arduino uno for show some light effects. also a ESP8266-01 module is connected to my arduino for receiving values from wifi.
before turning on the leds, everyting is ok and I can receive values truely by wifi and see them in serial monitor. But when my program sends commands to ws2812 leds, ESP8266 cant receive values truely and serial monitor shows garbag values as received values. It seems some kind of sincronization problem occures after turning ws2812 leds on. can you help me underestand what is happening?
this is my arduino code:
#include<FastLED.h>
#define NUM_LEDS 45
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX
CRGB leds[NUM_LEDS];
int v1, v2, v3, v4, ret, colr;
String inData;
void setup() {
FastLED.addLeds<NEOPIXEL,5>(leds, NUM_LEDS); ret = 0;
Serial.begin(9600); // communication with the host computer
// Start the software serial for communication with the ESP8266
ESPserial.begin(9600);
Serial.println("");
Serial.println("Remember to to set Both NL & CR in the serial monitor.");
Serial.println("Ready");
Serial.println("");
ESPserial.write("AT+CIPMUX=1\r\n");
delay(50);
ESPserial.write("AT+CIPSERVER=1,8888\r\n");
}
void loop(){
while (ESPserial.available()){
inData = ESPserial.readStringUntil('\n');
Serial.println(inData);
}
v1 = 0;
v2 = 0;
v3 = 0;
v4 = 0;
v1 = digitalRead(A0);
v2 = digitalRead(A1);
v3 = digitalRead(A2);
v4 = digitalRead(A3);
if (v1 == true && v2 == false && v3 == false && v4 == false) {
right_7(colr,150,0,255,0,0);
}
}
void right_7(int R, int G, int B, int DR, int DG, int DB) {
int s1[] = {0,0,3,10,20,40,70,100,130,255,0,0,0,0,0};
int s2[] = {0,0,0,3,10,20,40,70,100,130,255,0,0,0,0};
int s3[] = {0,0,3,10,20,40,70,100,130,255,0,0,0,0,0};
for(;;){
// fade everything out
for(int j=0; j<45; j++) { leds[j] = CRGB(DR,DG,DB);}
for(int i = 0; i < 15; i++) {
v1 = digitalRead(A0);
v2 = digitalRead(A1);
v3 = digitalRead(A2);
v4 = digitalRead(A3);
if (v1 == false || v2 == true || v3 == true || v4 == true) {ret = 1; return;}
// let's set an led value
if (s1[i]==255) leds[i] = CRGB(DR,DG,DB); else leds[i] = CRGB(s1[i]*R/255,s1[i]*G/255,s1[i]*B/255);
if (s2[i]==255) leds[29-i] = CRGB(DR,DG,DB); else leds[29-i] = CRGB(s2[i]*R/255,s2[i]*G/255,s2[i]*B/255);
if (s3[i]==255) leds[30+i] = CRGB(DR,DG,DB); else leds[30+i] = CRGB(s3[i]*R/255,s3[i]*G/255,s3[i]*B/255);
}
int tmp1 = s1[14];
int tmp2 = s2[14];
int tmp3 = s3[14];
for(int d = 14; d>0; d--) {
s1[d] = s1[d-1];
s2[d] = s2[d-1];
s3[d] = s3[d-1];
}
s1[0] = tmp1;
s2[0] = tmp2;
s3[0] = tmp3;
FastLED.show();
FastLED.delay(45);
}
}
this is my serial monitor output in begining of program run:
Remember to to set Both NL & CR in the serial monitor.
Ready
AT+CIPMUX=1
link is builded
ERROR
AT+CIPSERVER=1,8888
no change
OK
+IPD,0,4:test
but after turnin leds on, this is the serial monitor autput:
Remember to to set Both NL & CR in the serial monitor.
Ready
AT+CIPMUX=1
link is builded
ERROR
AT+CIPSERVER=1,8888
no change
OK
+IPD,0,4:test
0,CLOSED
0,CONNECT
+*⸮⸮Ңst
+I( f:re
my esp8266 shows "+*⸮⸮Ңst" as received value instead of "+IPD,0,4:test" string. what goes wrong with this ?