The Godfather talking
This is god damn my place! Capisci?
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 05, 2016, 11:27:19 11:27


Login with username, password and session length


Pages: [1]
Print
Author Topic: Multiple button press at a time.  (Read 872 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, 03:35:12 15: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: 976

Thank You
-Given: 197
-Receive: 344



« Reply #1 on: April 02, 2015, 04:09:40 16: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, 04:36:41 16: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
V.I.P
Junior Member
*****
Offline Offline

Posts: 53

Thank You
-Given: 146
-Receive: 97


« Reply #3 on: April 02, 2015, 05:07:16 17: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