Created
January 9, 2013 14:34
-
-
Save hilukasz/4493574 to your computer and use it in GitHub Desktop.
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
/* | |
code by Łukasz Wieczorek : http://hellowoo.com | |
feel free to modify code, just give me some credz | |
and keep this message in tact | |
kloveyou. | |
*/ | |
int IRpin = 3, | |
rawDataz, | |
values[4], | |
count, | |
average; | |
void setup() | |
{ | |
Serial.begin(9600); | |
pinMode(IRpin, INPUT); | |
} | |
void loop() | |
{ | |
// only count every 4 values | |
if(count == 4){ | |
count = 0; | |
// here we get the average to smooth out the line a little | |
average = (values[0]+values[1]+values[3]+values[4])/4; | |
// send a headerish thing so we know we are | |
// getting the correct message when processing boots up | |
Serial.print("handSensor,"); | |
Serial.println(average, DEC); | |
} | |
values[count] = analogRead(IRpin); | |
delay(70); | |
count++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment