Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 21, 2024, 09:54:26 09:54


Login with username, password and session length


Pages: [1]
Print
Author Topic: Multiple button press at a time.  (Read 8146 times)
0 Members and 1 Guest are viewing this topic.
7hills
Inactive

Offline Offline

Posts: 5

Thank You
-Given: 7
-Receive: 1


« on: April 02, 2015, 02:35:12 14:35 »

Dear All,

I want to press two buttons at a time to do something but no luck. Pls see my code below. Im doing this due to I/O shortage. All individual codes are working perfectly except two button code.

Again:
 
  If PORTB.0 = 0 And  PORTB.1 = 0 Then ' this is what im trying to do but no luck.
   DelayMS 50
   Toggle LED_Green
   While PORTB.0 = 0 and PORTB.1 = 0 : Wend
   DelayMS 50
   End If
 
          ' below codes are working. 
 If PORTB.0 = 0 Then
   DelayMS 50
  Toggle LED_Red
   While PORTB.0 = 0  : Wend
   DelayMS 50
   End If
 
   
  If PORTB.1 = 0 Then
   DelayMS 50
  Toggle LED_blue
   While PORTB.1 = 0  : Wend
   DelayMS 50
   End If
 
     
GoTo Again


 
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1203

Thank You
-Given: 553
-Receive: 409



« Reply #1 on: April 02, 2015, 03:09:40 15:09 »

Try this because your getting locked up in the wend loop

If PORTB.0 = 0 And  PORTB.1 = 0 Then ' this is what im trying to do but no luck.
      While PORTB.0 = 0 and PORTB.1 = 0
     DelayMS 100
     Toggle LED_Green
    Wend
    End If
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
7hills
Inactive

Offline Offline

Posts: 5

Thank You
-Given: 7
-Receive: 1


« Reply #2 on: April 02, 2015, 03:36:41 15:36 »

Hello.. Thanks for the reply. But still not working. instead its going to single press code and activates portb.0 and portb.1 individually. (LED blue and RED..Whichever button pressed first)

Regards.
Logged
giappolo
Active Member
***
Offline Offline

Posts: 147

Thank You
-Given: 1620
-Receive: 601


« Reply #3 on: April 02, 2015, 04:07:16 16:07 »

Sorry for my basic, test it


Again:
 
 
 If PORTB.0 = 0 Then
   DelayMS 200 'max delay between double key press
   If PORTB.1 = 0 Then
     DelayMS 50
     Toggle LED_Green
   Else         
    DelayMS 50
    Toggle LED_Red
   EndIf
   While PORTB.0 = 0 OR PORTB.1 = 0 : Wend
   DelayMS 50
   End If
 
   
 If PORTB.1 = 0 Then
   DelayMS 200 'max delay between double key press
   If PORTB.0 = 0 Then
     DelayMS 50
     Toggle LED_Green
   Else         
    DelayMS 50
    Toggle LED_blue
   EndIf
   While PORTB.0 = 0 OR PORTB.1 = 0 : Wend
   DelayMS 50
   End If
 
     
GoTo Again
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC