This is the Entire Code,
void loop()
{
sensorvalue = digitalRead(sensorpin);
if (sensorvalue == HIGH)
{
digitalWrite(ledPin,LOW);
}
else
{
counter = counter +1;
delay(1000);
digitalWrite(ledPin,HIGH);
}
if (counter == 10)
{
color(0, 255, 0);
counter = 0;
}
}
void color (unsigned char red, unsigned char green, unsigned char blue) // the color generating function
{
analogWrite(redPin, 255-red);
analogWrite(bluePin, 255-blue);
analogWrite(greenPin, 255-green);
}
Application : to Encourage kids to exercise.. Once the kid wear this on and turn on what ever he do just move his hand wave up or down left or right the counter will count as 1. So i have to design the hardware to be intelligent to count and extract the value of how many time he activate the sensor.