- Thu Dec 31, 2015 3:09 pm
#37574
Hi, I have some issues with the esp and arduino I use the code below just for test and write in the eeprom all fine when tested in arduino uno, but I upload the code in the esp and have problems any one can help me with these thank you.
#include <EEPROM.h>
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
char password[16];
char password2[16];
char password3[16];
int i;
void setup() {
EEPROM.get(i,password);
// }
// initialize serial:
Serial.begin(9600);
// reserve 200 bytes for the inputString:
inputString.reserve(200);
Serial.println(password);
}
void loop() {
serialEvent(); //call the function
// print the string when a newline arrives:
if (stringComplete) {
// Serial.println(inputString);
inputString.toCharArray(password2, 16);
for (int e=0; e<16; e++)
{
i= password2[e];
password3[e] = password2[e];
// EEPROM.write(password[e], password[e]);
// Serial.println(i, DEC);
// Serial.println(i );
}
Serial.println(password3 );
Serial.println(password[2] );
EEPROM.put(i,password3);
// clear the string:
inputString = "";
stringComplete = false;
}
}
/*
SerialEvent occurs whenever a new data comes in the
hardware serial RX. This routine is run between each
time loop() runs, so using delay inside loop can delay
response. Multiple bytes of data may be available.
*/
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inChar == '\n') {
stringComplete = true;
}
}
}