I am trying to read the data from a slider(values from 0 to 255), display it in the text box, and when i press a button to send that value to ESP8266 and Arduino Mega. With that value i want to light up a led with the intensity given by the value of the slider. For the ESP8266 i have just the small chip (
), and in the arduino code i manage to do a function and set up the ESP8266 "manualy" to say so.This is my arduino code:
void setup()
{
Serial.begin(9600); // communication with the host computer
Serial1.begin(9600);
Serial.println("Remember to to set Both NL & CR in the serial monitor.");
Serial.println("Ready");
configESP();
}
void loop()
{
// listen for communication from the ESP8266 and then write it to the serial monitor
if ( Serial1.available() ) { Serial.write( Serial1.read() ); }
// listen for user input and send it to the ESP8266
if ( Serial.available() ) { Serial1.write( Serial.read() ); }
}
void configESP(void){
trimiteESP("AT+RST\r\n", 2000); // reset
trimiteESP("AT+UART_DEF=9600,8,1,0,0\r\n",2000); //set baud rate at 9600
trimiteESP("AT+CWMODE=2\r\n", 1000); // config as acces point
trimiteESP("AT+CIFSR\r\n", 1000); // read IP adress
trimiteESP("AT+CWSAP?\r\n", 2000); // read SSID
trimiteESP("AT+CIPMUX=1\r\n", 1000); // allow multiple conexions
trimiteESP("AT+CIPSERVER=1,80\r\n", 1000); // start server on port 80
}
void trimiteESP(String command, const int timeout)
{
String response = "";
Serial1.print(command); // send command
long int time = millis();
while ((time + timeout) > millis()) {
while (Serial1.available()) {
char c = Serial1.read(); // read next char
response += c;
}
}
Serial.println(response);
}
This is something i tried with the app builder:
-with the fisrt block a write the round value of the slider in the text box
-button 1 and 3 are things that i tried to send data to the ESP and arduino
-button 2 is just a delete text from textbox
Can somebody help, please?