I have created example code of what I want with VB.NET but I have no idea how to make the same functionality with C/C++.
Here's my VB.NET code
Dim i As Integer Private Sub Timer1_Tick(sender As Object, e As System.EventArgs) Handles Timer1.Tick LED2 = ON; Timer1.Stop() i = 0 End Sub Private Sub Timer2_Tick(sender As Object, e As System.EventArgs) Handles Timer2.Tick i = 0 Timer1.Stop() End Sub Private Sub Form1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown Timer1.Stop() Timer2.Start() i = i + 1 If i < 5 Then Timer1.Interval = 500 Timer1.Start() Timer2.Interval = 5000 Else LED1 = ON; Timer1.Stop() i = 0 Timer2.Interval = 5000 End If If i = 2 Then LED1 = ON; End If End Sub Private Sub Form1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp Timer1.Stop() LED2 = OFF; End Sub
I have cleaned some lines out of this code but I attach the original VB.NET project to this message.
Number of downloads: 23
In that code I ave used mousebutoon as a button, but meaning is that:
- When I press button 5 times in 5 seconds LED1 lights on and stays.
- When I press and hold same button over 0,5seconds LED2 lights on and stays on as long as I pres the button.
- When I press button 2 times in 5 seconds LED1 lights off.
Variable i will be set to 0 after each 5 seconds.
Is there any way of doing that in C and if is what I need to learn and search. I havent found any timer-functions from C, but I can't figure out how else could this be done. Suggestions, help, ideas, anything?
This post has been edited by TEH: 28 October 2011 - 09:30 AM