Hello everybody,
I am using the arduino to take sensor readings from a series of 9 thermistors. I want to use a time that each reading was (approximately) taken at and Im not quite sure the best way to use the millis or icros function to do it. Logically I want to:
1 look for a digital pin to go high (do nothing until this happens)
2 start a timer
3 carry out a code until i hit the reset button
the problem is that i am using a ttl signal that is on for 5ms and off for 2 ms (or something like that) I dont want the code to ever be able to go back into that while loop where the TTL might be low. heres my code just incase you want to see what i have done so far.
void setup()
{
Serial.begin(9600);
pinMode(TTLPin, INPUT);
Serial.println("#S|CPBLTST|[]#");
Serial.println("#S|THRMLOG|[Time;Vin0;Vin1;Vin2;Vin3;Vin4;Vin5;Vin6;Vin7;Vin8]#");
int tStart = micros();
}
void loop(){
while(TTLPin== LOW){
}
Vin0 = analogRead(v0Pin); Vin1 = analogRead(v1Pin); Vin2 = analogRead(v2Pin);
Vin3 = analogRead(v3Pin); Vin4 = analogRead(v4Pin); Vin5 = analogRead(v5Pin);
Vin6 = analogRead(v6Pin); Vin7 = analogRead(v7Pin); Vin8 = analogRead(v8Pin);
char buffer[7];
Serial.print("#S|THRMLOG|[");
tTest = micros() - tStart;
Serial.print(itoa((tTest), buffer, 10));
Serial.print(";");
Serial.print(itoa((Vin0), buffer, 10));
Serial.print(";");
Serial.print(itoa((Vin1), buffer, 10));
Serial.print(";");
Serial.print(itoa((Vin2), buffer, 10));
Serial.print(";");
Serial.print(itoa((Vin3), buffer, 10));
Serial.print(";");
Serial.print(itoa((Vin4), buffer, 10));
Serial.print(";");
Serial.print(itoa((Vin5), buffer, 10));
Serial.print(";");
Serial.print(itoa((Vin6), buffer, 10));
Serial.print(";");
Serial.print(itoa((Vin7), buffer, 10));
Serial.print(";");
Serial.print(itoa((Vin8), buffer, 10));
Serial.print(";");
Serial.println("]#");