![]() If the Timer0 isn't configured, it's interrupt cannot trigger and thus millis() will stay zero. The hardware timer generates interrupts with a specific frequency and in the corresponding ISR (Interrupt Service Routine) the variable for millis() is incremented. At that time neither millis(), nor delay() will work, since the hardware Timer0 is needed to be configured correctly for them to work. This is done in the main() function, which then after the first initializing calls setup() and loop().īut the creation of globally defined objects (and thus the execution of their constructors) is done even before the main() function. The Arduino framework does some initializing for you before going into setup() and loop(), for example configuring Timer0 correctly for millis(), delay() and siblings. MaxValue = 520 //default value - sensor under water MinValue = 0 //default value - sensor dry ![]() HistoryValue = currentValue //init history val define the cymbols on the buttons of the keypadsīyte rowPins = while(currentTime<(prevTime+delayTime)) //while time spent < 100ĬurrentValue = analogRead(analogPinNumber) //read analog valueĭigitalWrite(VCC_digitalPinNumber,LOW) //turn sensor OFF /Keypad parametrization and object creation LiquidCrystal* pLCD = new LiquidCrystal(rs, en, d4, d5, d6, d7) MG_RTC m圜lock //Object that contains specific clock functions to my project like printing date and time on the lcd.Ĭonst int rs = 2, en = 1, d4 = 4, d5 = 7, d6 = 8, d7 = 10 RTCDateTime dt //Struct from DS3231 lib - contains date and time Here is an extract from my ino file: #include ĭS3231 clock //Clock object -> contains basic Real Time Clock functions I'm using an Arduino mega2560 and a water level sensor in the follwing example. I also tried to replace delay by a loop using millis but the value returned by millis is always 0. ino file and the librairy Arduino.h is included in my cpp. ![]() hpp linked to the used cpp is well included in the. ino file) it works well but when I call the same function in an external cpp file, I'm stuck in the delay function. The issue is that when I used delay() in my main program (meaning. I'm currently facing an issue using delay() and millis() functions in an external cpp file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |