Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#define pIn 8
int cumulative_time = 0;
int MAX_DURATION = 500 * 1000;
byte timeD[5000];
String signalR = "";
void setup() {
pinMode(pIn, INPUT);
Serial.begin(9600);
}
void loop() {
long beginning_time = micros() / 1000;
for ( int i = 0; cumulative_time < MAX_DURATION; i++) {
int time_delta = micros() / 1000 - beginning_time;
timeD[i] = (time_delta);
signalR += digitalRead(pIn);
cumulative_time = time_delta;
}
for(int i=0;i<signalR.length();i++){
Serial.println(timeD[i],signalR[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment