Skip to content

Instantly share code, notes, and snippets.

@hilukasz
Created January 9, 2013 14:34
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 hilukasz/4493574 to your computer and use it in GitHub Desktop.
Save hilukasz/4493574 to your computer and use it in GitHub Desktop.
/*
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