I want to define an unknown size for an array. However, I know that this cannot be done on the arduino. So what other methods do you suggest? I tried using vectors by downloading the library ArduinoSTL, but it doesnt work. (It only prints Serial.println(Signal); once, referring to the code in the pastebin link below)
Here's my code with vectors:
#include <ArduinoSTL.h>
#define sensor1 A0
using namespace std;
int Signal;
int Threshold = 550;
vector<int> startTime;
vector<int> endTime;
unsigned long measureTime;
void setup() {
Serial.begin(9600);
}
void loop()
{
//Serial.println(analogRead(sensor1));
int i = 0;
measureTime = millis();
while ((millis() - measureTime) < 10000)
{
Signal = analogRead(sensor1);
Serial.println(Signal);
if (Signal < Threshold)
{
startTime.at(i) = millis();
Serial.println("1");
}
if (Signal > Threshold)
{
endTime.at(i) = millis();
Serial.println("2");
}
i++;
}
}