The code (as attached) uploads properly, but displays the wrong output ins serial window.
Please tell as to why this is happening.
Can I not use setup() again in loop()? Why?
Did you read read this before posting a programming question ?
It has useful advice on posting a programming question properly
You could call setup() from loop() but why would you want to or need to ?
Post your code in the forum using code tags. A screen shot of your code is utterly useless.
my bad guys. sorry
Wouldn't you expect Serial.begin(9600); to clear the buffer it is controlling?
Serial.print(F("some data"));and similar routines put the output in a buffer and return.
The buffer will be emptied in the background with the configured speed.
So you are throwing away the buffer that was filled correctly with begin() in setup().
For a test you could insert a Serial.flush(); before calling setup, this routine waits until the tx buffer is empty.
Basically it's not a good idea to call setup again, if you need functionality that already exists in setup,
make it a function that can be called from everywhere.
