I’ve attributed some weird behavior to my lack of C++ expertise. However, I decided to spend a couple of days to track down missing serial output on my USB COM3 Windows 10 port. After trying a bunch of simple tests and finding a hint in documentation about serial stuff happening in Loop(), I verified that Setup() terminates (dies, aborts) on Serial.begin(9600) and so my missing output like version # and important initialization wasn’t happening. Of course, this led to strange program behavior. I now use a first time flag and do my initialization out of Loop() and no more strange behavior. I had a lot of headaches with this because the early abort meant my firstTime flag wasn’t being set.
@Erhughes1944, I always use Serial.begin() in setup() and never had any problems. If you can share you code, I may be able to advise.
I think the lower bound for Serial.available()
might be 0 --> https://docs.particle.io/reference/firmware/electron/#available-
I usually use while(!Serial.available()
Something minimal to test:
int counter = 20;
void setup(){
counter = -10;
Serial.begin(9600);
}
void loop(){
if(Serial.available()){ //hit any button
Serial.read();
Serial.println(counter);
}
}
Update: oh yeah it should be all lowercase setup()
retract retract Setup() s/b setup() arghh!
Here is an overview of some tricks to make your posts look nice
Forum Tips and Tricks