Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
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
You can’t perform that action at this time.