Very new to Arduino but here goes. I'm designing a bell control box for a sound stage that has to function as follows:
Press Roll PB:
Turn on red light
Ring Bell for 1 sec.
Flash "Rolling" Indicator
Pulse (250ms) Recorder Roll Control
Press Cut PB
Turn off red light
Ring Bell twice for 250 ms.
Turn off Flashing "Rolling" Indicator
Pulse (250ms) Recorder Stop Control
I've managed to learn and use many examples I've found online and have gotten everything to work very well except one function. I can't seem to ring the bell for the two short bursts when the "Cut" PB is pressed. Right now I'm using a routine to detect a transition to trigger the bell because I only want it to ring twice no matter how long the "Cut" PB is depressed.
The following code will trigger properly on the "Cut" PB transition and produces one 250 ms. pulse, but no matter what kind of delays and loop counters I've tried I just can't get it to work for a second time.
I've tried to marry the two but have not had any luck yet. Thoughts?
BTW the logic for the program flow (which is working perfectly except for this problem) I wrote, but the routines for the transition detection and timing were gathered online so my understanding of their operation is fundamental at best.
Yep, the semicolons at the end of the if statements were wrong: my bad, but I saw the curly brace at the end of his if statement and not knowing what was after the last line I was just throwing in an idea.
Well guys that looked great and thank you for the timely response but trying it didn't seem to help. As TomGeorge suggested I'm posting the entire code to see if that put things into better prospective. Please ignore the comments since much of the code segments were captured online. I'm still hacking away at it trying to figure this out but it is an awesome learning experience.
It would be much easier to make sense of your code (for you and for us) if you divide it up into functions to separate the details from the logic. Have a look at planning and implementing a program.
Then your code in loop() could be something close to the description in your original post. Something like
This was my first attempt so I knew it wouldn't be pretty. The scary thing is that I used to be a pretty good assembly level programmer and even worked with C++, but that was 25 years ago. I have been relearning everything.
Thanks for the tips, once I get it working I'll teach myself more about structure and clean it up.
Any recommend literature that you think would help?