push button routine
I have a NO push button when I press the button my debug changes btn2=0 to btn2 = 1. When btn2 = 1 then mode = mode + 1. When mode =1 then light a led.
IF Btn2 = 1 THEN
mode = mode + 1
IF mode = 1 THEN HIGH 14
IF mode = 0 THEN LOW 14
I'm sure theres a few ways to get it to latch.
It dosent matter how long I hold down the push button the debug terminal shows a constant value of 1 for Btn2. The modes debug value constantly changes from 0 to 1 depending on how long I hold the button. I need the mode led to only change once no matter how long I hold the button. Im not sure how to code it? If I could get a suggestion for this portion I can work on the rest.
Overview:
The code is part of a larger controller/ boe bot/ xbee project. Eventually I'd like when mode = 1 then my left right joystick controls the ping servo's movement proportional to the joystick.Instead of turning the boe bot. While sending the ping readings to the controllers lcd screen. If not during the movement just after movement stops send the ping reading.
If you want to see more of the codes I have I can post them. Thanks ahead of time.
IF Btn2 = 1 THEN
mode = mode + 1
IF mode = 1 THEN HIGH 14
IF mode = 0 THEN LOW 14
I'm sure theres a few ways to get it to latch.
It dosent matter how long I hold down the push button the debug terminal shows a constant value of 1 for Btn2. The modes debug value constantly changes from 0 to 1 depending on how long I hold the button. I need the mode led to only change once no matter how long I hold the button. Im not sure how to code it? If I could get a suggestion for this portion I can work on the rest.
Overview:
The code is part of a larger controller/ boe bot/ xbee project. Eventually I'd like when mode = 1 then my left right joystick controls the ping servo's movement proportional to the joystick.Instead of turning the boe bot. While sending the ping readings to the controllers lcd screen. If not during the movement just after movement stops send the ping reading.
If you want to see more of the codes I have I can post them. Thanks ahead of time.
Comments
I'd say, post your code so we can see all the nuances. :thumb:
I'm not understanding the explanation/description given.
Ok Im back, took my kids out Trick or Treatn. Yes Erco I have pull down resistors on both of my push buttons. These are the latest codes I have. They are still in a rough design phase. A few lines arent being used. They have the apostrophe inserted. Where I was trying to get a time out function working.
http://www.youtube.com/watch?v=KYnqRgbv6PU&feature=g-crec-u
It's kind of a crappy video, Idk hope it helps
edit: I fixed that also. When mode = 1 the LR joystick only controls the ping servo. The problem of how long I hold Btn2 down and the mode flickering 0,1,0,1 is still an issue. I also still am not getting the ping reading back to the contollers LCD yet.
boe code contoller code
CODE REVISED see here http://forums.parallax.com/showthread.php?143290-xbee-not-recieving-proper-values
post #8
Looking at your code there is no use of the BUTTON command as debounce and when you press the button you could be adding +1 to the variable "mode" several times,you're conditions only allow for mode to be 1 or 0 you need to make sure mode cannot be higher than 1 if the button contacts bounce or if the button is pressed more than once by putting something like IF mode >1 then mode =1 in your code.
You see, what that does is to cause mode to flip only when the button input makes the transition from 0 to 1. So you have to release the button and press it again to flip the mode back.