I am using a piezo vibro sensor to activate an alarm. I need my alarm to be on for 2 seconds then stop an turn on next time it has vibration here is my code so far.
const int sensorPin = A0;
int value = 0;
const int alarm = 13;
pinMode (alarm, OUTPUT);
pinMode (sensorPin, INPUT);
value = analogRead(sensorPin);
So, after you turn the alarm on, you need a two second delay()? I'm not sure if there is a function for that, or not.
I think you'll find that you get a lot more feedback if you:
- Read the first two posts (i.e., "sticky notes") on this forum that tell you how to get the most out of this forum.
- With the cursor in the Source Code window of the IDE, press Ctrl-T to format your code in a form preferred by most readers.
- Use the source code tags (using the '#' character you see when you post a comment) to encompass your formatted code.
This will make it easier for everyone to help you.