Skip to content

Instantly share code, notes, and snippets.

@t-kashima
Created May 21, 2015 14:52
Show Gist options
  • Save t-kashima/53b87ef68eab67696926 to your computer and use it in GitHub Desktop.
Save t-kashima/53b87ef68eab67696926 to your computer and use it in GitHub Desktop.
Red-rays distance sensor for Android
void setup() {
Serial.begin(9600);
pinMode(11, OUTPUT);
digitalWrite(11, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
int sum = 0;
for (int i = 0; i < 100; i++) {
sum += analogRead(0);
}
int average = sum / 100;
Serial.println(average);
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment