pfeerick / elapsedMillis

Arduino 'port' of the elapsedMillis library
MIT License
84 stars 26 forks source link

Library not functioning on Intel Edison #10

Open doctim77 opened 7 years ago

doctim77 commented 7 years ago

Curiously, the library does not appear to be functioning on the Intel Edison.

This is a sample code. Does not print to the serial monitor. If I comment out the timer however, it prints just fine.

Any thoughts why this may be the case? I am perplexed.

# include <elapsedMillis.h>

elapsedMillis stimer0; // global timer
void setup() {

}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Waiting...");
  while (stimer0 < 1000)
  {
    //do nothing, just pause
  }

}
pfeerick commented 7 years ago

There are a couple of things wrong with that sample. I'm assuming the first, the incomplete #include line is irrelevant, as that would never complie ;)

More importantly, do you still need to do a Serial.begin(9600); (or other baud rate) on the Intel Edison? I don't have one of those, but I would expect it is still needed. Give this code a try (you should be able to copy and paste the whole thing into a new sketch), and let me know what happens. I'm expecting output like

Waiting..............
Wait over
#include <elapsedMillis.h>

elapsedMillis stimer0; // global timer
void setup() 
{
  Serial.begin(9600);
}

void loop()
{
  Serial.println();
  Serial.print("Waiting...");

  while (stimer0 < 1000)
  {
    Serial.print(".");
    delay(100);
  }

  //if wait time elapsed
  if (stimer0 > 1000)
  {
    Serial.println();
    Serial.print("Wait over");
    while (1); //this makes the code hang/stop... don't do this in normal practice!
  }
}
doctim77 commented 7 years ago

Thanks for the quick reply and sorry about the coding errors. It was late and I was being sloppy. Nonetheless, it will still not work. I tested yours, pulled the header file into the sketch directly, but still nothing seems to work. I am able to print millis(), so I am confident that is not the problem.

On two Edison's, having the same problem.

#include "elapsedMillisEdison.h"

elapsedMillis timer1;

void setup() {
  // put your setup code here, to run once:

  Serial.begin(115200);

}

void loop() {

  Serial.println(timer1);
  delay(1000);

}

Thanks for your help. I am heavily relying on multiple timers for my code and this library has been a blessing. Just need to figure out why it is not working on the Edison. Thanks.