Skip to content

Instantly share code, notes, and snippets.

@carlcrott
Last active November 17, 2016 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlcrott/adda61ccdf173fb2519f930cc30fe090 to your computer and use it in GitHub Desktop.
Save carlcrott/adda61ccdf173fb2519f930cc30fe090 to your computer and use it in GitHub Desktop.
#define TEMP_PIN_05 5
const int READING_COUNT = 5;
int val_05[READING_COUNT];
const int how_many = 5;
bool run_once = true;
int read_05 = 0;
//int val_06 = 0;
//int val_07 = 0;
void setup() {
Serial.begin(38400);
}
void loop() {
if ( run_once ){
Serial.println("starting");
for ( int j=0; j < how_many; j++){
// recording
for( int i=0; i<READING_COUNT-1; i++) {
// drop value at index 0 and shift remaining values left by 1
val_05[i] = val_05[i+1];
}
read_05 = analogRead(TEMP_PIN_05);
val_05[READING_COUNT] = read_05;
// Printing
for (int k = 0; k < READING_COUNT; k++){
Serial.print(val_05[k]);
if ( k < READING_COUNT - 1) Serial.print(","); // commas between
}
Serial.println("");
}
Serial.println("Finished");
run_once = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment