#include <vector.h> and <sys/time.h> , For use with atmega328p, it is possible to use these libraries with this Microcontroller

I am trying to explain an example but I have had problems using these two libraries when defining them, there is any possibility of using them, I am new to PlatformIO, I am using an arduinoNano, which I would have to modify in .ini, in order to be able to use them of these two libraries, thank you very much in advance for the support, the community looks incredible and more PlatformIO.

The C standard library’s time.h is includable.

#include "Arduino.h"
#include <time.h>

void setup() {
    time_t currentTime = time(NULL);
void loop() { }

compiles – the question is what exact functionality do you expect from it. The Atmega328P has no real-time-clock / RTC peripheral to hold the time. There are workarounds with timers et cetera, but these are not given by the standard C library.

For vector.h: Do you really want to use the Standard Template Library, and this datastructure, which allocates its elements on the heap? On such a memory constrained device like a ATMega328P? Not a good I think. AVR-GCC doesn’t have <vector.h> by default – you have to use libraries which fill the gap there, as described in Arduino c++11 or c++14 support in platform IO - #3 by maxgerhardt.

1 Like

I am trying to copy this example from youtube, and I see that the author uses the following libraries
#include <sys / time.h> /
using namespace std;
#include “vector.h”

Now my doubt is that if the library that he uses <sys / time.h> needs a real time clock, or is similar to the library #include <time.h>, the author uses HiLetgo ESP32 - OLED WiFi Kit for Arduino ESP8266 NodeMCU and I an arduino nano, is it possible that it works on my arduino nano ???

this is the example DavesGarageLEDSeries/bounce.h at master · davepl/DavesGarageLEDSeries · GitHub

Greetings and thanks for the help .

In the specific example you’ve shown, I’ve just seen the Time() function being used as a timing reference for the animation. That would still work with just directly calling millis(), so it doesn’t actually need an RTC… also, the time is not synchronized anywhere in the sketch, although it could be done using NTP and WiFi with the ESP32 that the project runs on.

Also, all the std::vector objects I see can simply be replaced by arrays of doubles with ballCount elements, since no vector specific functions are called – just assignments to specific indices. It’s just over-engineered.