using one button to change states, in c programming

Status
Not open for further replies.

winnie mong

Junior Member level 3
Joined
Sep 8, 2013
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
366
hi, guys.
i am using c programming to implement my programmable timer switch.so there is some part of the code where i want to be able to toggle between displaying 'set hours"and set minutes so that i can use an increment button to set the relevant time.
i want to ask for help on how to toggle between set hours and set minutes minutes states using c programming using the select button.
Thanx
 

int prev_press

prev_press = 1;
.
.
.
.
..
if (button_pushed())
{
if ( prev_press ) { prev_press = 0; set_hours();} else { prev_press = 1; set_minutes();}
}
 
thnx a lot kam1787
wl try apply the code into the one i already have.
but then i am using the four character alphanumeric display, so as the two digits of the hours OR minutes are activated distinctively by toggle button, ready to be incremented to the desired value from zero, i would like to show the user that they can set the relevant side by the blinking of the two respective digits,while the remaining two are off until they are activated by the toggling button.
so my question is how to make two zeros blink on the relevant choice "in c programming"as one presses the button switching between set minutes and set hours states, so that they can then be able to increment and save their time setting.
thanx..
 

I don;t know what C compiler you are using, but usually there is a delay function.

or you could use the difference in time if it goes to the millisecond level
 

i am using HCPIC v9.83, it can go to milliseconds yes.and wow, i think the delay function will work.
thanks.
 

hi guys.
i am working on this project"programmable timer switch" to set geyser ON time and OFF time, i have fabricated my timer and tested it with a sample code.it uses PIc16f84, an alphanumeric display, relay and three buttons (one takes the user from default state to the menu, the other toggles between setting minutes and setting hours while the last is used for incrementing).i have to be implementing the timer finite state machine using c programming which is a challenge to me.

so i wanted to ask for help.i have small pieces of codes that are workinh but they seem to be just the small portion of the main thing. i am poor with the programming
 

i want to be able to use the increment button,so i can set the time.so at each button press, there should be an increment on the display until i reach the number i want to save as the time setting.
how do i code in c, i was trying to use the for loop, the numbers are incrementing to the end at a single button press when i want them to be incrementing once at a button press.
thank you..
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…