Go Down

Topic: General Program Outline Assistance (Read 91 times) previous topic - next topic

Crezblaine

Hello Everyone,

I am in need of assistance for a program I am building that can do a couple of things. I have not started yet, really just looking for some guidance at this point, but here is what I want it to do.

1.) I have a start button that begins a process and when it is pressed, I want it to add 1 to two counters keeping track of how many times it is pressed.
So for example (When Cycle Start button is HIGH add 1 to Counter 1 and Counter 2)

2.) Once counter 1 reaches 100, I will have a yellow light come on along with a speaker sound for a certain period of time (already know how to do that), but then I want the counter to reset back to zero and begin counting with the button presses again.

3.) Once counter 2 reaches 200,  I will have a red light come on along with a speaker sound for a certain period of time (already know how to do that), but then I want the counter to reset back to zero and begin counting with the button presses again.

*In essence steps 2 & 3 are the same

These are basically just cycle counts that give off indicator lights and sounds when a certain count is reached. Does anyone have a good idea of how to build a general outline for this so I know at least the bare bones of how to begin? Then I can fill in the rest. I'm not a total lost cause  :smiley-sweat:



neiklot

Have a look here; it's pretty much what you want.

I prefer to change the logic though. Make the pin an input_pullup in pinmode so it's normally high, then look for a low which is when it gets pressed. Button would then be from pin to ground, not to 5V as they have it in that example.


Robin2

Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up