How to make ' As you sow, so you shall reap ' Device at home
This project is a very simple type of Arduino project which works like an Artificial Intelligence. This circuit counts the number of times the speaker taped and report back the number of tapes with tones.
This circuit is only for fun purposes by using the Arduino microcontroller.
Circuit
diagram...
Coding
byte tapCount = 0;
long int tapTime = millis();
void setup()
{
Serial.begin(9600);
}
void loop()
{
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
if(sensorValue > 40) //detect a tap
{
delay(70);
tapCount = tapCount + 1; //increment tap count
tapTime = millis(); //record current system time
}
if(tapTime < (millis() - 400)) //if more than 0.4 seconds have elapsed since last tap
{
for(int x=0; x < tapCount; x++)
{
pinMode(A0,OUTPUT);
tone(A0, 1500);
delay(200);
noTone(A0);
delay(200);
pinMode(A0,INPUT);
}
tapCount = 0;
}
delay(5); // delay in between reads for stability
} //loop
Comments
Post a Comment