My first idea was to create some sort of tempo, much like a metronome is used to set a rythm.
I aimed to have wires holding in the hands with the use of conductible tape, and have the claps registered and transmitted to the LED. When the two 'sensors' touch each other in the palm of one's hands, the light will lighten.
There will be two lights -- the red one which senses your movement and lights up at the contact, and the green one which measures a constant rythm. The 'goal' would be to synchronise both to reach consistency and musical hearing.
For every 5 seconds, the person must clap their hand a minimum of time for the light to light up.
Here was the source code --
//now() > seconds
int claps = 0;
long start = millis();
//arduino settings
void setup()
{
pinMode(2,OUTPUT);
pinMode(3,INPUT);
Serial.begin(9600);
}
void loop()
{
if(digitalRead(3) == HIGH)
{
claps++;
Serial.print("clap");
delay(30);
}
if(millis()-start > 1000)
{
//if more than 15 claps per 5 seconds, light up
if(claps>5)
{
digitalWrite(2, HIGH);
}
else
{
//if less than 15 claps per 5 seconds, light out
digitalWrite(2,LOW);
}
//current settings
claps = 0;
start = millis();
}
}
Aucun commentaire:
Enregistrer un commentaire