Go Down

Topic: How do I create a confirmation and activation script? (Read 737 times) previous topic - next topic

benzure

For example, if the boolean is true it will flash a small LED using millis not delay.

Simple enough right? BUT there needs to be a time out, so if it's NOT TRUE AGAIN within 3 seconds and still under 4 successful times, it resets a value.

However, if the boolean is true 4 times within 3 seconds between them then it lights up the full light array.

Any ideas would be much appreciated! I think my brain has melted attempting this!

PaulS

Quote
Simple enough right?

Yes.

Quote
BUT there needs to be a time out, so if it's NOT TRUE AGAIN within 3 seconds and still under 4 successful times, it resets a value.

You need to define what causes the LED to think it needs to flash. You need to determine how long it has been since that event last occurred. You need to clear that flag if the time has been exceeded or if the number of failed attempts is excessive.

Arrch


Am I on the right sort of tracks with this?

Well, you're certainly not going to win any "Code Readability" Awards. There is an Auto Format tool in the Arduino's IDE that I recommend you get yourself acquainted with.

PaulS

Quote
There is an Auto Format tool in the Arduino's IDE that I recommend you get yourself acquainted with.

There is also the Verify icon that will attempt to compile and link, but not upload, your code. Posting code that at least compiles is considered polite, unless the question is "why won't my code compile?"

Arrch


PaulS

Quote
I've followed directions Arrch and the code above is verified and auto formatted...

I'm calling bullshit!
Code: [Select]
void loop(){


if (digitalRead(inPin)==HIGH&&globalValue==0) { // true and only if 0
Serial.println("confirm"); // print confirmation


That is NOT properly formatted.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy