Skip to content

Instantly share code, notes, and snippets.

@madeintaiwan
Created September 2, 2013 09:05
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 madeintaiwan/6410820 to your computer and use it in GitHub Desktop.
Save madeintaiwan/6410820 to your computer and use it in GitHub Desktop.
The Arduino code for Tom Igoe's graphing processing code
/*
Read in five analog sensor values, send them out
as tab-delimited ASCCI-encoded decimal numbers,
ended by a carriage return and newline
created 15 Oct. 2007
*/
void setup() {
// iniaialize the serial port:
Serial.begin(9600);
}
void loop() {
// count from 0 to 4 (five channels):
for (int channel=0; channel <=4; channel++) {
// read an analog input, divide the result by 4
// to limit it to 0-255:
int sensorValue = analogRead(channel)/4;
// print it:
Serial.print(sensorValue, DEC);
// if it's not the last channel to be read,
// print a tab character:
if (channel < 4) {
Serial.print("\t");
}
// delay to let the analog-to-digital converter settle:
delay(8);
}
// once you've printed all the values,
// print a newline and carriage return:
Serial.println();
}
@madeintaiwan
Copy link
Author

@lpetre
Copy link

lpetre commented Sep 2, 2013

Yes, this is printing out tab separated values to the serial port, reading for give analog ports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment