Mini Bowling Alley ...
 
Notifications
Clear all

Mini Bowling Alley Pin Setter coding project In need of tutoring...

169 Posts
7 Users
4 Likes
40.2 K Views
(@zeferby)
Member
Joined: 5 years ago
Posts: 355
 
Posted by: @pugwash

Can't get shorter than that???

That's true, though I am wondering : why detach ?

Anyway, here is the Holy Book of ATMega328 Interrupts !

Eric


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 
Posted by: @zeferby
Posted by: @pugwash

Can't get shorter than that???

That's true, though I am wondering : why detach ?

Anyway, here is the Holy Book of ATMega328 Interrupts !

I will have to read it.

Why detach?

I usually detach an interrupt until the boolean value has been changed back to its original state.


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

Just a really simple example that does not block interrupts like delay() does.

volatile bool flag = false;

void setup() {
  attachInterrupt(digitalPinToInterrupt(2), changeFlag, CHANGE);
}

void loop() {

  for(,,){
    // do anything you want to while flag has not been set
    // anything here runs for ever until the interrupt is fired
    if(flag){
      flag = !flag;
      break;
      }
    }

}

void changeFlag(){
  flag = !flag; //toggle flag from false to true
  }

 


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 
Posted by: @dundervetter

Would it be possible to create another case/state for a complete and total reset of the system?  

@dundervetter

What happens if you press the reset button on the Arduino?

Maybe write your own delay routine that aborts when a button is pressed?

I will give it some thought with your current source code in mind.  In the meantime a challenge for all coders to come up with the best solution 🙂

 


   
ReplyQuote
Page 12 / 12