Created
September 2, 2013 09:05
-
-
Save madeintaiwan/6410820 to your computer and use it in GitHub Desktop.
The Arduino code for Tom Igoe's graphing processing code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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(); | |
} |
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
http://wiki.processing.org/w/Tom_Igoe_Interview
from there