Help with an idea (k8055)

I need an ideea
If I press the first button what code must I write in order to verify that the second button is pressed after one (1) second
I need to verify that the second button is pressed after one second

I use Visual Basic

I hope I made myself clear

You can do this using a timer and a global variable in your program.

  1. When the button is pressed for the first time, restart the 1 second timer and set the global variable.
  2. When timer event occurs, reset the global variable.
  • The global variable is set for one second after the first button press.
  • When the next button press occurs, you may check if the variable is set or not.

Please see also:
viewtopic.php?f=3&t=3655
viewtopic.php?f=15&t=4501

Thank you for the response

[code]Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
If CheckBox5.Checked = True Then
objWriter.WriteLine(“second button pressed”)
objWriter.WriteLine(DateTime.Now.ToLongTimeString())
Timer3.Enabled = False

    End If
    p = p + 1
    If p = 10 Then Timer3.Enabled = False
End Sub

Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged
    If CheckBox4.Checked Then
        objWriter.WriteLine("first button pushed")
        objWriter.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString())
        p = 0
        Timer3.Enabled = True

    End If
End Sub

[/code]

With this code if the first button is pressed I check using 0.1s steps if the second button is pressed until one second passes

What I want to happen is to verify the second button only after the first button is no longer pressed.

With the current code if I press the first button and I hold my finger on it for more than one second it no longer checks if the second button is pressed. How can I modify the code?

Also do you have the circuit diagram/ circuit desing of K8055 in document form. Like the ones in the booklets

[quote]With the current code if I press the first button and I hold my finger on it for more than one second it no longer checks if the second button is pressed. How can I modify the code?[/quote]You have to check the button state change.
Start the timer when the button is released.

[quote]Also do you have the circuit diagram/ circuit desing of K8055 in document form. Like the ones in the booklets[/quote]Here is the link to download the circuit diagram: box.net/shared/k2bh8larvn

[quote=“VEL255”]You have to check the button state change.
Start the timer when the button is released.
[/quote]

How do I do that?

Here is a slightly modified code.
Now the timer is enabled when button 1 is released.

changed:If CheckBox4.Checked Thento:If Not CheckBox4.Checked Then

Other modification concerns the way to detect if the second button is pressed.
In your code this is checked every 100ms.
More reliable detection you get by using a boolean variable.
When the button 2 is pressed this variable is set.
Now you can check in the timer routine if the button was pressed within 1 second after the first button was released.

[code]Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
If button_2 = True Then
objWriter.WriteLine(“second button pressed”)
objWriter.WriteLine(DateTime.Now.ToLongTimeString())
Timer3.Enabled = False
button_2 = False
End If
p = p + 1
If p = 10 Then Timer3.Enabled = False
End Sub

Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged
    If Not CheckBox4.Checked Then
        objWriter.WriteLine("first button released")
        objWriter.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString())
        p = 0
        button_2 = False
        Timer3.Enabled = True
    End If
End Sub

Private Sub CheckBox5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox5.CheckedChanged
    If CheckBox5.Checked Then
        button_2 = True
    End If
End Sub[/code]

Thank you very very much