I'm not sure this line is valid. Try with this commented out.
And your code doesn't show where FILE is from.
Don't have any help for your LEDs except write a simple sketch that only controls the LEDs and see if you can fine where things are going wrong. My guess would be LED pin identification but can't say why your code isn't correct.
__FILE__ is a built-in predeifned macro generated at compile time. I do not know if this applies to the ESP8266, it certainly applies to avr-gcc the Arduino AVR core.
//Edit
It does not seem to be avr-gcc where it comes from.
Serial.print does surely work in setup()
This is my bare-minimum Testcode for ESP8266
int myCounter = 0;
void PrintFileNameDateTime() {
Serial.println( F("Code running comes from file ") );
Serial.println( F(__FILE__) );
Serial.print( F(" compiled ") );
Serial.print( F(__DATE__) );
Serial.print( F(" ") );
Serial.println( F(__TIME__) );
}
// easy to use helper-function for non-blocking timing
boolean TimePeriodIsOver (unsigned long &startOfPeriod, unsigned long TimePeriod) {
unsigned long currentMillis = millis();
if ( currentMillis - startOfPeriod >= TimePeriod ) {
// more time than TimePeriod has elapsed since last time if-condition was true
startOfPeriod = currentMillis; // a new period starts right here so set new starttime
return true;
}
else return false; // actual TimePeriod is NOT yet over
}
unsigned long MyTestTimer = 0; // Timer-variables MUST be of type unsigned long
const byte OnBoard_LED = 2;
void BlinkHeartBeatLED(int IO_Pin, int BlinkPeriod) {
static unsigned long MyBlinkTimer;
pinMode(IO_Pin, OUTPUT);
if ( TimePeriodIsOver(MyBlinkTimer,BlinkPeriod) ) {
digitalWrite(IO_Pin,!digitalRead(IO_Pin) );
}
}
void setup() {
Serial.begin(115200);
Serial.println("Setup-Start");
PrintFileNameDateTime();
}
void loop() {
BlinkHeartBeatLED(OnBoard_LED,100);
if ( TimePeriodIsOver(MyTestTimer,1000) ) {
Serial.print("Hello World ");
myCounter++;
Serial.println(myCounter);
}
}
I guess
if you replace the comma with a semicolon it will work
Me personal I don't like it when two function-calls are in one line
one possible reason is:
uploading the new code did not happen
best regards Stefan
The function Serial.print doesn't works well, I got only output from the Serial.prints inside loop, I don't see any characters from the Serial.prints in function setup
what?
the constant LED2 was assigned the value 2 I changed the value to 5
I still have the LED physically connected to IO-pin 2 and the LED is still switching on/off why?
My original thought was the "," separating the two "lines" of code. However I was confused why if the syntax was incorrect the compiler did not flag it. So I learned that as well.
Now I would know if it was the processor type or my code is at fault.
I also use the "blink without delay" example to verify the board is still working (or not) when I get into a situation where I think the board may be at fault.
Thanks for the answers of the first question.
How about the others please?
2. 'A' changes by MIT APP, even not sensitive as excepted, 'B' never changed;
3. the LED2 was signed at 2, I changed it to 5, it still works on 2, why?
For the LEDs I would use the "blink without delay" and test the function of one LED at a time by changing the sketch pinout to what you are using. What you describe is hard to grasp knowing how the processor works, so there must be more to it. I think the above will show the issue and get you going.
You will find the above is my approach to how I solve problems with my own code. It is the best way I know of to sort out issues.