Created
August 26, 2013 15:33
-
-
Save halfd/6342783 to your computer and use it in GitHub Desktop.
The code running on the arduino
This file contains hidden or 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
const int COUNT = 3; | |
int out0; | |
int out1; | |
int out2; | |
int out3; | |
int out4; | |
// the setup routine runs once when you press reset: | |
void setup() { | |
// initialize serial communication at 9600 bits per second: | |
Serial.begin(9600); | |
digitalWrite(A0, HIGH); | |
digitalWrite(A1, HIGH); | |
digitalWrite(A2, HIGH); | |
digitalWrite(A3, HIGH); | |
digitalWrite(A4, HIGH); | |
} | |
int average(int out) { | |
return (int)(out / COUNT); | |
} | |
// the loop routine runs over and over again forever: | |
void loop() { | |
for (int i = 0; i < COUNT; i++) { | |
out0 += analogRead(A0); | |
delay(2); | |
out1 += analogRead(A1); | |
delay(2); | |
out2 += analogRead(A2); | |
delay(2); | |
out3 += analogRead(A3); | |
delay(2); | |
out4 += analogRead(A4); | |
delay(2); | |
} | |
Serial.print(average(out0)); | |
Serial.print("-"); | |
Serial.print(average(out1)); | |
Serial.print("-"); | |
Serial.print(average(out2)); | |
Serial.print("-"); | |
Serial.print(average(out3)); | |
Serial.print("-"); | |
Serial.print(average(out4)); | |
Serial.println(""); | |
out0 = 0; | |
out1 = 0; | |
out2 = 0; | |
out3 = 0; | |
out4 = 0; | |
delay(2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment